skybridge 0.0.0-dev.c003b05 → 0.0.0-dev.c006b0b
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/README.md +126 -124
- package/dist/cli/build-helpers.d.ts +11 -0
- package/dist/cli/build-helpers.js +107 -0
- package/dist/cli/build-helpers.js.map +1 -0
- package/dist/cli/build-helpers.test.js +132 -0
- package/dist/cli/build-helpers.test.js.map +1 -0
- package/dist/cli/build-steps.d.ts +2 -0
- package/dist/cli/build-steps.js +73 -0
- package/dist/cli/build-steps.js.map +1 -0
- package/dist/cli/build-steps.test.js +52 -0
- package/dist/cli/build-steps.test.js.map +1 -0
- package/dist/cli/detect-port.d.ts +2 -2
- package/dist/cli/detect-port.js +8 -20
- package/dist/cli/detect-port.js.map +1 -1
- package/dist/cli/header.d.ts +1 -1
- package/dist/cli/header.js.map +1 -1
- package/dist/cli/resolve-skybridge-config.d.ts +5 -0
- package/dist/cli/resolve-skybridge-config.js +18 -0
- package/dist/cli/resolve-skybridge-config.js.map +1 -0
- package/dist/cli/run-command.js.map +1 -1
- package/dist/cli/run-plain.d.ts +18 -0
- package/dist/cli/run-plain.js +89 -0
- package/dist/cli/run-plain.js.map +1 -0
- package/dist/cli/telemetry.js.map +1 -1
- package/dist/cli/tunnel-control-server.d.ts +9 -0
- package/dist/cli/tunnel-control-server.js +31 -0
- package/dist/cli/tunnel-control-server.js.map +1 -0
- package/dist/cli/tunnel-control-server.test.js +39 -0
- package/dist/cli/tunnel-control-server.test.js.map +1 -0
- package/dist/cli/tunnel-handler.d.ts +3 -0
- package/dist/cli/tunnel-handler.js +48 -0
- package/dist/cli/tunnel-handler.js.map +1 -0
- package/dist/cli/tunnel-handler.test.js +105 -0
- package/dist/cli/tunnel-handler.test.js.map +1 -0
- package/dist/cli/tunnel.d.ts +57 -0
- package/dist/cli/tunnel.js +154 -0
- package/dist/cli/tunnel.js.map +1 -0
- package/dist/cli/tunnel.test.js +190 -0
- package/dist/cli/tunnel.test.js.map +1 -0
- package/dist/cli/types.js.map +1 -1
- package/dist/cli/use-execute-steps.d.ts +1 -1
- package/dist/cli/use-execute-steps.js.map +1 -1
- package/dist/cli/use-messages.js.map +1 -1
- package/dist/cli/use-nodemon.d.ts +14 -0
- package/dist/cli/use-nodemon.js +82 -54
- package/dist/cli/use-nodemon.js.map +1 -1
- package/dist/cli/use-open-browser.d.ts +1 -0
- package/dist/cli/use-open-browser.js +44 -0
- package/dist/cli/use-open-browser.js.map +1 -0
- package/dist/cli/use-tunnel.d.ts +1 -1
- package/dist/cli/use-tunnel.js +102 -68
- package/dist/cli/use-tunnel.js.map +1 -1
- package/dist/cli/use-typescript-check.d.ts +9 -2
- package/dist/cli/use-typescript-check.js +89 -51
- package/dist/cli/use-typescript-check.js.map +1 -1
- package/dist/commands/build.d.ts +0 -3
- package/dist/commands/build.js +2 -38
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/create.d.ts +9 -0
- package/dist/commands/create.js +30 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dev.d.ts +2 -0
- package/dist/commands/dev.js +81 -2
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.js +7 -1
- package/dist/commands/start.js.map +1 -1
- package/dist/commands/telemetry/disable.js.map +1 -1
- package/dist/commands/telemetry/enable.js.map +1 -1
- package/dist/commands/telemetry/status.js.map +1 -1
- package/dist/context-warnings.d.ts +5 -0
- package/dist/context-warnings.js +31 -0
- package/dist/context-warnings.js.map +1 -0
- package/dist/context-warnings.test.js +28 -0
- package/dist/context-warnings.test.js.map +1 -0
- package/dist/server/app.d.ts +175 -0
- package/dist/server/app.js +275 -0
- package/dist/server/app.js.map +1 -0
- package/dist/server/asset-base-url-transform-plugin.d.ts +1 -0
- package/dist/server/asset-base-url-transform-plugin.js +17 -2
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.test.js +80 -1
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
- package/dist/server/auth/discovery.d.ts +33 -0
- package/dist/server/auth/discovery.js +56 -0
- package/dist/server/auth/discovery.js.map +1 -0
- package/dist/server/auth/discovery.test.d.ts +1 -0
- package/dist/server/auth/discovery.test.js +93 -0
- package/dist/server/auth/discovery.test.js.map +1 -0
- package/dist/server/auth/index.d.ts +30 -0
- package/dist/server/auth/index.js +2 -0
- package/dist/server/auth/index.js.map +1 -0
- package/dist/server/auth/providers/auth0.d.ts +40 -0
- package/dist/server/auth/providers/auth0.js +31 -0
- package/dist/server/auth/providers/auth0.js.map +1 -0
- package/dist/server/auth/providers/auth0.test.d.ts +1 -0
- package/dist/server/auth/providers/auth0.test.js +50 -0
- package/dist/server/auth/providers/auth0.test.js.map +1 -0
- package/dist/server/auth/providers/authplane.d.ts +49 -0
- package/dist/server/auth/providers/authplane.js +57 -0
- package/dist/server/auth/providers/authplane.js.map +1 -0
- package/dist/server/auth/providers/authplane.test.d.ts +1 -0
- package/dist/server/auth/providers/authplane.test.js +140 -0
- package/dist/server/auth/providers/authplane.test.js.map +1 -0
- package/dist/server/auth/providers/clerk.d.ts +51 -0
- package/dist/server/auth/providers/clerk.js +19 -0
- package/dist/server/auth/providers/clerk.js.map +1 -0
- package/dist/server/auth/providers/clerk.test.d.ts +1 -0
- package/dist/server/auth/providers/clerk.test.js +30 -0
- package/dist/server/auth/providers/clerk.test.js.map +1 -0
- package/dist/server/auth/providers/custom.d.ts +40 -0
- package/dist/server/auth/providers/custom.js +56 -0
- package/dist/server/auth/providers/custom.js.map +1 -0
- package/dist/server/auth/providers/custom.test.d.ts +1 -0
- package/dist/server/auth/providers/custom.test.js +158 -0
- package/dist/server/auth/providers/custom.test.js.map +1 -0
- package/dist/server/auth/providers/descope.d.ts +44 -0
- package/dist/server/auth/providers/descope.js +44 -0
- package/dist/server/auth/providers/descope.js.map +1 -0
- package/dist/server/auth/providers/descope.test.d.ts +1 -0
- package/dist/server/auth/providers/descope.test.js +62 -0
- package/dist/server/auth/providers/descope.test.js.map +1 -0
- package/dist/server/auth/providers/shared.d.ts +2 -0
- package/dist/server/auth/providers/shared.js +6 -0
- package/dist/server/auth/providers/shared.js.map +1 -0
- package/dist/server/auth/providers/shared.test.d.ts +1 -0
- package/dist/server/auth/providers/shared.test.js +10 -0
- package/dist/server/auth/providers/shared.test.js.map +1 -0
- package/dist/server/auth/providers/stytch.d.ts +25 -0
- package/dist/server/auth/providers/stytch.js +16 -0
- package/dist/server/auth/providers/stytch.js.map +1 -0
- package/dist/server/auth/providers/verify-spy.d.ts +12 -0
- package/dist/server/auth/providers/verify-spy.js +21 -0
- package/dist/server/auth/providers/verify-spy.js.map +1 -0
- package/dist/server/auth/providers/workos.d.ts +33 -0
- package/dist/server/auth/providers/workos.js +15 -0
- package/dist/server/auth/providers/workos.js.map +1 -0
- package/dist/server/auth/security-schemes.d.ts +23 -0
- package/dist/server/auth/security-schemes.js +64 -0
- package/dist/server/auth/security-schemes.js.map +1 -0
- package/dist/server/auth/security-schemes.test.d.ts +1 -0
- package/dist/server/auth/security-schemes.test.js +99 -0
- package/dist/server/auth/security-schemes.test.js.map +1 -0
- package/dist/server/auth/setup.d.ts +6 -0
- package/dist/server/auth/setup.js +91 -0
- package/dist/server/auth/setup.js.map +1 -0
- package/dist/server/auth/setup.test.d.ts +1 -0
- package/dist/server/auth/setup.test.js +512 -0
- package/dist/server/auth/setup.test.js.map +1 -0
- package/dist/server/auth/verify.d.ts +46 -0
- package/dist/server/auth/verify.js +62 -0
- package/dist/server/auth/verify.js.map +1 -0
- package/dist/server/auth/verify.test.d.ts +1 -0
- package/dist/server/auth/verify.test.js +149 -0
- package/dist/server/auth/verify.test.js.map +1 -0
- package/dist/server/auth-extra.test-d.d.ts +1 -0
- package/dist/server/auth-extra.test-d.js +71 -0
- package/dist/server/auth-extra.test-d.js.map +1 -0
- package/dist/server/auth.d.ts +57 -0
- package/dist/server/auth.js +27 -0
- package/dist/server/auth.js.map +1 -0
- package/dist/server/build-manifest.test.d.ts +1 -0
- package/dist/server/build-manifest.test.js +28 -0
- package/dist/server/build-manifest.test.js.map +1 -0
- package/dist/server/content-helpers.d.ts +41 -1
- package/dist/server/content-helpers.js +33 -0
- package/dist/server/content-helpers.js.map +1 -1
- package/dist/server/content-helpers.test.js.map +1 -1
- package/dist/server/express.d.ts +23 -7
- package/dist/server/express.js +59 -30
- package/dist/server/express.js.map +1 -1
- package/dist/server/express.test.js +338 -71
- package/dist/server/express.test.js.map +1 -1
- package/dist/server/factory-loader.test.d.ts +1 -0
- package/dist/server/factory-loader.test.js +81 -0
- package/dist/server/factory-loader.test.js.map +1 -0
- package/dist/server/file-ref.d.ts +28 -0
- package/dist/server/file-ref.js +27 -0
- package/dist/server/file-ref.js.map +1 -0
- package/dist/server/host.d.ts +2 -0
- package/dist/server/host.js +11 -0
- package/dist/server/host.js.map +1 -0
- package/dist/server/host.test.d.ts +1 -0
- package/dist/server/host.test.js +13 -0
- package/dist/server/host.test.js.map +1 -0
- package/dist/server/index.d.ts +17 -2
- package/dist/server/index.js +14 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/inferUtilityTypes.d.ts +6 -6
- package/dist/server/inferUtilityTypes.js.map +1 -1
- package/dist/server/mcp-errors.test.d.ts +1 -0
- package/dist/server/mcp-errors.test.js +37 -0
- package/dist/server/mcp-errors.test.js.map +1 -0
- package/dist/server/metric.js.map +1 -1
- package/dist/server/middleware.d.ts +51 -13
- package/dist/server/middleware.js +33 -0
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/middleware.test-d.js +1 -1
- package/dist/server/middleware.test-d.js.map +1 -1
- package/dist/server/middleware.test.js +190 -131
- package/dist/server/middleware.test.js.map +1 -1
- package/dist/server/register-tool.test.d.ts +1 -0
- package/dist/server/register-tool.test.js +23 -0
- package/dist/server/register-tool.test.js.map +1 -0
- package/dist/server/requestOrigin.d.ts +7 -0
- package/dist/server/requestOrigin.js +25 -0
- package/dist/server/requestOrigin.js.map +1 -0
- package/dist/server/server.d.ts +329 -41
- package/dist/server/server.js +469 -251
- package/dist/server/server.js.map +1 -1
- package/dist/server/skills-integration.test.d.ts +1 -0
- package/dist/server/skills-integration.test.js +79 -0
- package/dist/server/skills-integration.test.js.map +1 -0
- package/dist/server/skills.d.ts +27 -0
- package/dist/server/skills.js +188 -0
- package/dist/server/skills.js.map +1 -0
- package/dist/server/skills.test.d.ts +1 -0
- package/dist/server/skills.test.js +243 -0
- package/dist/server/skills.test.js.map +1 -0
- package/dist/server/templateHelper.d.ts +0 -5
- package/dist/server/templateHelper.js +3 -22
- package/dist/server/templateHelper.js.map +1 -1
- package/dist/server/templates.generated.d.ts +4 -0
- package/dist/server/templates.generated.js +43 -0
- package/dist/server/templates.generated.js.map +1 -0
- package/dist/server/tool-extra.test.d.ts +1 -0
- package/dist/server/tool-extra.test.js +72 -0
- package/dist/server/tool-extra.test.js.map +1 -0
- package/dist/server/tunnel-proxy-router.d.ts +7 -0
- package/dist/server/tunnel-proxy-router.js +110 -0
- package/dist/server/tunnel-proxy-router.js.map +1 -0
- package/dist/server/tunnel-proxy-router.test.d.ts +1 -0
- package/dist/server/tunnel-proxy-router.test.js +229 -0
- package/dist/server/tunnel-proxy-router.test.js.map +1 -0
- package/dist/server/view-name.test-d.d.ts +1 -0
- package/dist/server/view-name.test-d.js +8 -0
- package/dist/server/view-name.test-d.js.map +1 -0
- package/dist/server/view-resource-resolution.test.d.ts +6 -0
- package/dist/server/view-resource-resolution.test.js +172 -0
- package/dist/server/view-resource-resolution.test.js.map +1 -0
- package/dist/server/viewsDevServer.js +4 -1
- package/dist/server/viewsDevServer.js.map +1 -1
- package/dist/test/utils.d.ts +9 -11
- package/dist/test/utils.js +18 -13
- package/dist/test/utils.js.map +1 -1
- package/dist/test/view.test.js +195 -113
- package/dist/test/view.test.js.map +1 -1
- package/dist/version.js +1 -3
- package/dist/version.js.map +1 -1
- package/dist/views/index.d.ts +10 -0
- package/dist/views/index.js +3 -0
- package/dist/views/index.js.map +1 -0
- package/dist/{web/plugin → views}/scan-views.d.ts +8 -0
- package/dist/{web/plugin → views}/scan-views.js +26 -8
- package/dist/views/scan-views.js.map +1 -0
- package/dist/views/scan-views.test.d.ts +1 -0
- package/dist/{web/plugin → views}/scan-views.test.js +33 -1
- package/dist/views/scan-views.test.js.map +1 -0
- package/dist/views/validate-view.d.ts +1 -0
- package/dist/{web/plugin → views}/validate-view.js +2 -2
- package/dist/views/validate-view.js.map +1 -0
- package/dist/views/validate-view.test.d.ts +1 -0
- package/dist/views/validate-view.test.js.map +1 -0
- package/dist/web/bridges/adaptor.d.ts +51 -0
- package/dist/web/bridges/adaptor.js +327 -0
- package/dist/web/bridges/adaptor.js.map +1 -0
- package/dist/web/bridges/adaptor.test.d.ts +1 -0
- package/dist/web/bridges/adaptor.test.js +225 -0
- package/dist/web/bridges/adaptor.test.js.map +1 -0
- package/dist/web/bridges/apps-sdk/bridge.d.ts +6 -1
- package/dist/web/bridges/apps-sdk/bridge.js +15 -3
- package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
- package/dist/web/bridges/apps-sdk/index.d.ts +0 -1
- package/dist/web/bridges/apps-sdk/index.js +0 -1
- package/dist/web/bridges/apps-sdk/index.js.map +1 -1
- package/dist/web/bridges/apps-sdk/types.d.ts +8 -1
- package/dist/web/bridges/apps-sdk/types.js.map +1 -1
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +11 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +11 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
- package/dist/web/bridges/get-adaptor.d.ts +7 -0
- package/dist/web/bridges/get-adaptor.js +9 -7
- package/dist/web/bridges/get-adaptor.js.map +1 -1
- package/dist/web/bridges/get-adaptor.test.d.ts +1 -0
- package/dist/web/bridges/get-adaptor.test.js +32 -0
- package/dist/web/bridges/get-adaptor.test.js.map +1 -0
- package/dist/web/bridges/index.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.d.ts +15 -2
- package/dist/web/bridges/mcp-app/bridge.js +73 -7
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.test.d.ts +1 -0
- package/dist/web/bridges/mcp-app/bridge.test.js +17 -0
- package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -0
- package/dist/web/bridges/mcp-app/index.d.ts +0 -1
- package/dist/web/bridges/mcp-app/index.js +0 -1
- package/dist/web/bridges/mcp-app/index.js.map +1 -1
- package/dist/web/bridges/mcp-app/types.d.ts +2 -0
- package/dist/web/bridges/mcp-app/types.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +12 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +12 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
- package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
- package/dist/web/bridges/mcp-app/view-tools.test.js +143 -0
- package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
- package/dist/web/bridges/types.d.ts +120 -10
- package/dist/web/bridges/types.js +14 -1
- package/dist/web/bridges/types.js.map +1 -1
- package/dist/web/bridges/types.test.d.ts +1 -0
- package/dist/web/bridges/types.test.js +19 -0
- package/dist/web/bridges/types.test.js.map +1 -0
- package/dist/web/bridges/use-host-context.d.ts +5 -0
- package/dist/web/bridges/use-host-context.js +5 -0
- package/dist/web/bridges/use-host-context.js.map +1 -1
- package/dist/web/components/modal-provider.d.ts +1 -1
- package/dist/web/components/modal-provider.js +4 -3
- package/dist/web/components/modal-provider.js.map +1 -1
- package/dist/web/create-store.d.ts +26 -0
- package/dist/web/create-store.js +35 -9
- package/dist/web/create-store.js.map +1 -1
- package/dist/web/create-store.test.js +24 -23
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.d.ts +35 -2
- package/dist/web/data-llm.js +31 -3
- package/dist/web/data-llm.js.map +1 -1
- package/dist/web/data-llm.test.js +42 -29
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +15 -12
- package/dist/web/generate-helpers.js +12 -9
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/generate-helpers.test-d.js +14 -12
- package/dist/web/generate-helpers.test-d.js.map +1 -1
- package/dist/web/generate-helpers.test.js +2 -2
- package/dist/web/generate-helpers.test.js.map +1 -1
- package/dist/web/helpers/state.d.ts +2 -2
- package/dist/web/helpers/state.js +11 -11
- package/dist/web/helpers/state.js.map +1 -1
- package/dist/web/helpers/state.test.js +9 -9
- package/dist/web/helpers/state.test.js.map +1 -1
- package/dist/web/hooks/index.d.ts +7 -2
- package/dist/web/hooks/index.js +7 -2
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/test/utils.d.ts +7 -2
- package/dist/web/hooks/test/utils.js +14 -3
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-call-tool.d.ts +45 -0
- package/dist/web/hooks/use-call-tool.js +28 -0
- package/dist/web/hooks/use-call-tool.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test.js +64 -29
- package/dist/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/web/hooks/use-display-mode.d.ts +20 -0
- package/dist/web/hooks/use-display-mode.js +20 -0
- package/dist/web/hooks/use-display-mode.js.map +1 -1
- package/dist/web/hooks/use-display-mode.test-d.js.map +1 -1
- package/dist/web/hooks/use-display-mode.test.js +57 -21
- package/dist/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/web/hooks/use-download.d.ts +3 -0
- package/dist/web/hooks/use-download.js +7 -0
- package/dist/web/hooks/use-download.js.map +1 -0
- package/dist/web/hooks/use-download.test.d.ts +1 -0
- package/dist/web/hooks/use-download.test.js +103 -0
- package/dist/web/hooks/use-download.test.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +32 -0
- package/dist/web/hooks/use-files.js +32 -0
- package/dist/web/hooks/use-files.js.map +1 -1
- package/dist/web/hooks/use-files.test.js +11 -3
- package/dist/web/hooks/use-files.test.js.map +1 -1
- package/dist/web/hooks/use-host.d.ts +22 -0
- package/dist/web/hooks/use-host.js +30 -0
- package/dist/web/hooks/use-host.js.map +1 -0
- package/dist/web/hooks/use-host.test.d.ts +1 -0
- package/dist/web/hooks/use-host.test.js +59 -0
- package/dist/web/hooks/use-host.test.js.map +1 -0
- package/dist/web/hooks/use-open-external.d.ts +17 -0
- package/dist/web/hooks/use-open-external.js +16 -0
- package/dist/web/hooks/use-open-external.js.map +1 -1
- package/dist/web/hooks/use-open-external.test.js +15 -5
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-register-view-tool.d.ts +37 -0
- package/dist/web/hooks/use-register-view-tool.js +50 -0
- package/dist/web/hooks/use-register-view-tool.js.map +1 -0
- package/dist/web/hooks/use-request-close.d.ts +16 -0
- package/dist/web/hooks/use-request-close.js +21 -0
- package/dist/web/hooks/use-request-close.js.map +1 -0
- package/dist/web/hooks/use-request-close.test.d.ts +1 -0
- package/dist/web/hooks/use-request-close.test.js +47 -0
- package/dist/web/hooks/use-request-close.test.js.map +1 -0
- package/dist/web/hooks/use-request-modal.d.ts +16 -1
- package/dist/web/hooks/use-request-modal.js +19 -4
- package/dist/web/hooks/use-request-modal.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js +12 -2
- package/dist/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/web/hooks/use-request-size.d.ts +20 -0
- package/dist/web/hooks/use-request-size.js +24 -0
- package/dist/web/hooks/use-request-size.js.map +1 -0
- package/dist/web/hooks/use-request-size.test.d.ts +1 -0
- package/dist/web/hooks/use-request-size.test.js +47 -0
- package/dist/web/hooks/use-request-size.test.js.map +1 -0
- package/dist/web/hooks/use-send-follow-up-message.d.ts +19 -1
- package/dist/web/hooks/use-send-follow-up-message.js +19 -2
- package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.d.ts +17 -0
- package/dist/web/hooks/use-set-open-in-app-url.js +17 -0
- package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.test.js +26 -12
- package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
- package/dist/web/hooks/use-tool-info.d.ts +46 -14
- package/dist/web/hooks/use-tool-info.js +29 -7
- package/dist/web/hooks/use-tool-info.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test-d.js +11 -34
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +42 -37
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.d.ts +5 -2
- package/dist/web/hooks/use-user.js +6 -3
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +85 -37
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/dist/web/hooks/use-view-state.d.ts +25 -0
- package/dist/web/hooks/use-view-state.js +42 -0
- package/dist/web/hooks/use-view-state.js.map +1 -0
- package/dist/web/hooks/use-view-state.test.d.ts +1 -0
- package/dist/web/hooks/{use-widget-state.test.js → use-view-state.test.js} +56 -21
- package/dist/web/hooks/use-view-state.test.js.map +1 -0
- package/dist/web/hooks/use-viewport.d.ts +20 -0
- package/dist/web/hooks/use-viewport.js +21 -0
- package/dist/web/hooks/use-viewport.js.map +1 -0
- package/dist/web/hooks/use-viewport.test.d.ts +1 -0
- package/dist/web/hooks/use-viewport.test.js +109 -0
- package/dist/web/hooks/use-viewport.test.js.map +1 -0
- package/dist/web/index.d.ts +1 -3
- package/dist/web/index.js +1 -2
- package/dist/web/index.js.map +1 -1
- package/dist/web/mount-view.d.ts +21 -0
- package/dist/web/mount-view.js +43 -0
- package/dist/web/mount-view.js.map +1 -0
- package/dist/web/proxy.js.map +1 -1
- package/dist/web/types.d.ts +4 -0
- package/dist/web/types.js.map +1 -1
- package/package.json +45 -28
- package/dist/server/templates/development.hbs +0 -12
- package/dist/server/templates/production.hbs +0 -6
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +0 -24
- package/dist/web/bridges/apps-sdk/adaptor.js +0 -87
- package/dist/web/bridges/apps-sdk/adaptor.js.map +0 -1
- package/dist/web/bridges/mcp-app/adaptor.d.ts +0 -48
- package/dist/web/bridges/mcp-app/adaptor.js +0 -268
- package/dist/web/bridges/mcp-app/adaptor.js.map +0 -1
- package/dist/web/hooks/use-layout.d.ts +0 -22
- package/dist/web/hooks/use-layout.js +0 -23
- package/dist/web/hooks/use-layout.js.map +0 -1
- package/dist/web/hooks/use-layout.test.js +0 -96
- package/dist/web/hooks/use-layout.test.js.map +0 -1
- package/dist/web/hooks/use-widget-state.d.ts +0 -4
- package/dist/web/hooks/use-widget-state.js +0 -32
- package/dist/web/hooks/use-widget-state.js.map +0 -1
- package/dist/web/hooks/use-widget-state.test.js.map +0 -1
- package/dist/web/mount-widget.d.ts +0 -1
- package/dist/web/mount-widget.js +0 -27
- package/dist/web/mount-widget.js.map +0 -1
- package/dist/web/plugin/data-llm.test.js +0 -81
- package/dist/web/plugin/data-llm.test.js.map +0 -1
- package/dist/web/plugin/plugin.d.ts +0 -5
- package/dist/web/plugin/plugin.js +0 -141
- package/dist/web/plugin/plugin.js.map +0 -1
- package/dist/web/plugin/scan-views.js.map +0 -1
- package/dist/web/plugin/scan-views.test.js.map +0 -1
- package/dist/web/plugin/transform-data-llm.d.ts +0 -12
- package/dist/web/plugin/transform-data-llm.js +0 -96
- package/dist/web/plugin/transform-data-llm.js.map +0 -1
- package/dist/web/plugin/transform-data-llm.test.js +0 -81
- package/dist/web/plugin/transform-data-llm.test.js.map +0 -1
- package/dist/web/plugin/validate-view.d.ts +0 -1
- package/dist/web/plugin/validate-view.js.map +0 -1
- package/dist/web/plugin/validate-view.test.js.map +0 -1
- /package/dist/{web/hooks/use-layout.test.d.ts → cli/build-helpers.test.d.ts} +0 -0
- /package/dist/{web/hooks/use-widget-state.test.d.ts → cli/build-steps.test.d.ts} +0 -0
- /package/dist/{web/plugin/data-llm.test.d.ts → cli/tunnel-control-server.test.d.ts} +0 -0
- /package/dist/{web/plugin/scan-views.test.d.ts → cli/tunnel-handler.test.d.ts} +0 -0
- /package/dist/{web/plugin/transform-data-llm.test.d.ts → cli/tunnel.test.d.ts} +0 -0
- /package/dist/{web/plugin/validate-view.test.d.ts → context-warnings.test.d.ts} +0 -0
- /package/dist/{web/plugin → views}/validate-view.test.js +0 -0
package/dist/server/server.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import crypto from "node:crypto";
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
-
import http from "node:http";
|
|
4
3
|
import path from "node:path";
|
|
5
|
-
import { McpServer as McpServerBase } from "@modelcontextprotocol/
|
|
4
|
+
import { McpServer as McpServerBase, } from "@modelcontextprotocol/server";
|
|
6
5
|
import { mergeWith, union } from "es-toolkit";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
6
|
+
import { warnOnLargeToolOutput } from "../context-warnings.js";
|
|
7
|
+
import { authToSecuritySchemes, evaluateSecuritySchemes, inBandChallengeResult, } from "./auth/security-schemes.js";
|
|
8
|
+
import { hostFromUserAgent } from "./host.js";
|
|
9
|
+
import { captureToolError } from "./middleware.js";
|
|
10
|
+
import { resolveServerOrigin } from "./requestOrigin.js";
|
|
11
|
+
import { discoverSkills, registerSkills, SKILLS_EXTENSION_KEY, } from "./skills.js";
|
|
10
12
|
import { templateHelper } from "./templateHelper.js";
|
|
11
13
|
const mergeWithUnion = (target, source) => {
|
|
12
14
|
return mergeWith(target, source, (targetVal, sourceVal) => {
|
|
@@ -15,6 +17,35 @@ const mergeWithUnion = (target, source) => {
|
|
|
15
17
|
}
|
|
16
18
|
});
|
|
17
19
|
};
|
|
20
|
+
const SKILLS_DIR = "src/skills";
|
|
21
|
+
/**
|
|
22
|
+
* Normalize an `x-forwarded-prefix` value into a leading-slash, no-trailing-slash
|
|
23
|
+
* path. Takes the first hop of a comma-separated proxy chain.
|
|
24
|
+
* "/v1/", "v1", "/v1, /internal" → "/v1"; "", "/", undefined → "".
|
|
25
|
+
*/
|
|
26
|
+
function normalizeForwardedPrefix(raw) {
|
|
27
|
+
const firstHop = raw?.split(",")[0]?.trim() ?? "";
|
|
28
|
+
const trimmed = firstHop.replace(/\/+$/, "");
|
|
29
|
+
if (trimmed === "") {
|
|
30
|
+
return "";
|
|
31
|
+
}
|
|
32
|
+
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Drop the query string from a `ui://` view URI, leaving the bare path. The
|
|
36
|
+
* `?v=` cache key is the only query we append, so a plain split is enough and
|
|
37
|
+
* sidesteps `URL` normalization quirks on the non-special `ui:` scheme.
|
|
38
|
+
*/
|
|
39
|
+
function stripQuery(uri) {
|
|
40
|
+
const queryIndex = uri.indexOf("?");
|
|
41
|
+
return queryIndex === -1 ? uri : uri.slice(0, queryIndex);
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Coerce a tool handler's return value into an MCP `content` array. Strings
|
|
45
|
+
* become a single `TextContent`; a single block is wrapped in an array;
|
|
46
|
+
* `undefined` produces `[]`. Mostly used internally — exported so consumers
|
|
47
|
+
* who build content lazily can apply the same normalization.
|
|
48
|
+
*/
|
|
18
49
|
export function normalizeContent(content) {
|
|
19
50
|
if (content === undefined) {
|
|
20
51
|
return [];
|
|
@@ -28,53 +59,165 @@ export function normalizeContent(content) {
|
|
|
28
59
|
return [content];
|
|
29
60
|
}
|
|
30
61
|
const McpServerBaseOmitted = McpServerBase;
|
|
62
|
+
// Side channel populated by `dist/__entry.js` before user code is imported.
|
|
63
|
+
// Set at module scope rather than passed through the constructor because the
|
|
64
|
+
// wrapper has the manifest before the user's `new McpServer(...)` runs, and
|
|
65
|
+
// threading it through every call site (including user templates) is exactly
|
|
66
|
+
// the boilerplate this design is trying to hide.
|
|
67
|
+
let pendingBuildManifest = null;
|
|
68
|
+
/**
|
|
69
|
+
* Prime the build-time Vite manifest before user code constructs its
|
|
70
|
+
* `McpServer`. Called from the generated `dist/__entry.js`; not part of the
|
|
71
|
+
* user-facing API.
|
|
72
|
+
*
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
75
|
+
export function __setBuildManifest(manifest) {
|
|
76
|
+
pendingBuildManifest = manifest;
|
|
77
|
+
}
|
|
78
|
+
let pendingSkillsManifest = null;
|
|
79
|
+
let cachedDiskManifest = null;
|
|
80
|
+
let discoveredSkills = null;
|
|
81
|
+
let warnedOnMissingSkills = false;
|
|
82
|
+
export function __setSkillsManifest(manifest) {
|
|
83
|
+
pendingSkillsManifest = manifest;
|
|
84
|
+
discoveredSkills = null;
|
|
85
|
+
}
|
|
86
|
+
// Pure and `this`-free so it can run inside the `super(...)` call, before `this`
|
|
87
|
+
// exists — the capability must be present for the `initialize` response.
|
|
88
|
+
function withSkillsCapability(options, skybridgeOptions) {
|
|
89
|
+
if (!skybridgeOptions?.skills) {
|
|
90
|
+
return options;
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
...options,
|
|
94
|
+
capabilities: {
|
|
95
|
+
...options?.capabilities,
|
|
96
|
+
extensions: {
|
|
97
|
+
...options?.capabilities?.extensions,
|
|
98
|
+
[SKILLS_EXTENSION_KEY]: { directoryRead: true },
|
|
99
|
+
},
|
|
100
|
+
},
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Typed registration sugar over the MCP SDK's `McpServer`: a tool registry
|
|
105
|
+
* that carries input/output/meta shapes, view resources, per-tool security
|
|
106
|
+
* schemes, and prompt/resource registration. A {@link Skybridge} app builds
|
|
107
|
+
* one of these per request and hands it to your setup factory; chain
|
|
108
|
+
* {@link McpServer.registerTool} calls on it and return the result.
|
|
109
|
+
*
|
|
110
|
+
* The `TTools` generic accumulates each registered tool's input/output/meta
|
|
111
|
+
* shape, so `typeof app` carries enough information for view-side helpers
|
|
112
|
+
* like {@link generateHelpers} to produce fully-typed hooks.
|
|
113
|
+
*
|
|
114
|
+
* @typeParam TTools - Accumulated tool registry. Filled in by `registerTool`
|
|
115
|
+
* chaining; you almost never set this manually.
|
|
116
|
+
*
|
|
117
|
+
* @example
|
|
118
|
+
* ```ts
|
|
119
|
+
* export const app = new Skybridge({ name: "my-app", version: "1.0.0" }, (server) =>
|
|
120
|
+
* server.registerTool({
|
|
121
|
+
* name: "search",
|
|
122
|
+
* inputSchema: { query: z.string() },
|
|
123
|
+
* view: { component: "search" },
|
|
124
|
+
* }, async ({ query }) => ({ content: `Results for ${query}` })),
|
|
125
|
+
* );
|
|
126
|
+
* ```
|
|
127
|
+
*
|
|
128
|
+
* @see https://docs.skybridge.tech/api-reference/mcp-server
|
|
129
|
+
*/
|
|
31
130
|
export class McpServer extends McpServerBaseOmitted {
|
|
32
|
-
express;
|
|
33
|
-
customMiddleware = [];
|
|
34
|
-
customErrorMiddleware = [];
|
|
35
|
-
mcpMiddlewareEntries = [];
|
|
36
|
-
mcpMiddlewareApplied = false;
|
|
37
131
|
claimedViews = new Map();
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
132
|
+
viewMetaBuilders = new Map();
|
|
133
|
+
/**
|
|
134
|
+
* Maps a view resource's query-less path to its canonical registered URI
|
|
135
|
+
* (the one carrying the `?v=` cache key). Lets `resources/read` resolve the
|
|
136
|
+
* underlying view no matter which version param the consumer sends, since
|
|
137
|
+
* the param is only a cache key, not part of the resource's identity.
|
|
138
|
+
*/
|
|
139
|
+
viewUriByPath = new Map();
|
|
140
|
+
viteManifest = null;
|
|
141
|
+
oauthEnabled = false;
|
|
142
|
+
resolveResourceMetadataUrl;
|
|
143
|
+
toolSecuritySchemes = new Map();
|
|
144
|
+
userMiddlewareEntries = [];
|
|
145
|
+
constructor(serverInfo, options, skybridgeOptions) {
|
|
146
|
+
super(serverInfo, withSkillsCapability(options, skybridgeOptions));
|
|
147
|
+
this.oauthEnabled = Boolean(skybridgeOptions?.oauth);
|
|
148
|
+
// Pick up the manifest if `dist/__entry.js` primed it before importing
|
|
149
|
+
// user code. Explicit `setViteManifest` calls still win because they
|
|
150
|
+
// happen after construction.
|
|
151
|
+
if (pendingBuildManifest) {
|
|
152
|
+
this.setViteManifest(pendingBuildManifest);
|
|
49
153
|
}
|
|
154
|
+
this.setupSkills(Boolean(skybridgeOptions?.skills));
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The per-tool security schemes collected during registration, keyed by tool
|
|
158
|
+
* name. Read by the OAuth layer to decide whether anonymous requests are
|
|
159
|
+
* allowed and which schemes gate a given `tools/call`.
|
|
160
|
+
*
|
|
161
|
+
* @internal
|
|
162
|
+
*/
|
|
163
|
+
get securitySchemesByTool() {
|
|
164
|
+
return this.toolSecuritySchemes;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Inject the resolver the app uses to build the protected-resource metadata
|
|
168
|
+
* URL, so tool handlers can emit in-band auth challenges.
|
|
169
|
+
*
|
|
170
|
+
* @internal
|
|
171
|
+
*/
|
|
172
|
+
setResourceMetadataUrlResolver(resolve) {
|
|
173
|
+
this.resolveResourceMetadataUrl = resolve;
|
|
50
174
|
return this;
|
|
51
175
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
176
|
+
registerResource(...args) {
|
|
177
|
+
return this.applyInherited("registerResource", args);
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Register a prompt. Signature owned by Skybridge (not inherited) so a
|
|
181
|
+
* typed wrapper can land in a minor without a type-level break.
|
|
182
|
+
*/
|
|
183
|
+
registerPrompt(name, config, cb) {
|
|
184
|
+
return this.applyInherited("registerPrompt", [
|
|
185
|
+
name,
|
|
186
|
+
config,
|
|
187
|
+
cb,
|
|
188
|
+
]);
|
|
189
|
+
}
|
|
190
|
+
applyInherited(method, args) {
|
|
191
|
+
const base = McpServerBase.prototype[method];
|
|
192
|
+
return base.apply(this, args);
|
|
193
|
+
}
|
|
194
|
+
skillRegistrar() {
|
|
195
|
+
const registerResource = this.registerResource.bind(this);
|
|
196
|
+
return { registerResource, server: this.server };
|
|
197
|
+
}
|
|
198
|
+
setupSkills(enabled) {
|
|
199
|
+
if (!enabled) {
|
|
200
|
+
return;
|
|
55
201
|
}
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
});
|
|
202
|
+
discoveredSkills ??= pendingSkillsManifest ?? discoverSkills(SKILLS_DIR);
|
|
203
|
+
if (discoveredSkills.length === 0 && !warnedOnMissingSkills) {
|
|
204
|
+
warnedOnMissingSkills = true;
|
|
205
|
+
console.warn(`skybridge: the "skills" option is enabled but no skills were found in "${SKILLS_DIR}". Add a <name>/SKILL.md there, or remove the option.`);
|
|
60
206
|
}
|
|
61
|
-
|
|
207
|
+
registerSkills(this.skillRegistrar(), discoveredSkills);
|
|
62
208
|
}
|
|
63
209
|
mcpMiddleware(filterOrHandler,
|
|
64
210
|
// biome-ignore lint/suspicious/noExplicitAny: overloads narrow the handler type at call sites; implementation must accept all variants
|
|
65
211
|
maybeHandler) {
|
|
66
|
-
if (this.mcpMiddlewareApplied) {
|
|
67
|
-
throw new Error("Cannot register MCP middleware after run() or connect() has been called");
|
|
68
|
-
}
|
|
69
212
|
const handler = maybeHandler;
|
|
70
213
|
if (typeof filterOrHandler === "function") {
|
|
71
|
-
this.
|
|
214
|
+
this.userMiddlewareEntries.push({
|
|
72
215
|
filter: null,
|
|
73
216
|
handler: filterOrHandler,
|
|
74
217
|
});
|
|
75
218
|
}
|
|
76
219
|
else if (handler) {
|
|
77
|
-
this.
|
|
220
|
+
this.userMiddlewareEntries.push({
|
|
78
221
|
filter: filterOrHandler,
|
|
79
222
|
handler,
|
|
80
223
|
});
|
|
@@ -84,55 +227,96 @@ export class McpServer extends McpServerBaseOmitted {
|
|
|
84
227
|
}
|
|
85
228
|
return this;
|
|
86
229
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
230
|
+
/**
|
|
231
|
+
* This instance's protocol-level middleware: the framework's own entries
|
|
232
|
+
* (view `_meta` on `resources/list`, version-agnostic view resolution on
|
|
233
|
+
* `resources/read`, the top-level `securitySchemes` mirror on `tools/list`)
|
|
234
|
+
* followed by the ones registered via {@link McpServer.mcpMiddleware}.
|
|
235
|
+
*
|
|
236
|
+
* @internal
|
|
237
|
+
*/
|
|
238
|
+
protocolMiddlewareEntries() {
|
|
239
|
+
// Surface view-resource _meta on `resources/list` (per ext-apps spec:
|
|
240
|
+
// hosts/checkers read CSP & domain at list time before fetching content).
|
|
241
|
+
const viewListMetaEntry = {
|
|
242
|
+
filter: "resources/list",
|
|
243
|
+
handler: async (_req, extra, next) => {
|
|
244
|
+
const result = (await next());
|
|
245
|
+
for (const resource of result.resources) {
|
|
246
|
+
const builder = this.viewMetaBuilders.get(resource.uri);
|
|
247
|
+
if (!builder) {
|
|
248
|
+
continue;
|
|
249
|
+
}
|
|
250
|
+
const meta = builder(extra);
|
|
251
|
+
resource._meta = {
|
|
252
|
+
...(resource._meta ?? {}),
|
|
253
|
+
...meta,
|
|
254
|
+
};
|
|
255
|
+
}
|
|
256
|
+
return result;
|
|
257
|
+
},
|
|
106
258
|
};
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
259
|
+
// Resolve a view's `resources/read` by its query-less path so the
|
|
260
|
+
// underlying asset is served no matter the `?v=` value (stale cache key,
|
|
261
|
+
// no param, etc.). The version param is a cache-busting hint for external
|
|
262
|
+
// consumers; it must not gate resolution. We rewrite the lookup URI to the
|
|
263
|
+
// canonical registered one, then restore the requested URI on the response
|
|
264
|
+
// so the consumer-facing URI is never rewritten.
|
|
265
|
+
const viewReadResolveEntry = {
|
|
266
|
+
filter: "resources/read",
|
|
267
|
+
handler: async (req, _extra, next) => {
|
|
268
|
+
const requested = req.params.uri;
|
|
269
|
+
if (typeof requested !== "string") {
|
|
270
|
+
return next();
|
|
271
|
+
}
|
|
272
|
+
const path = stripQuery(requested);
|
|
273
|
+
const canonical = this.viewUriByPath.get(path);
|
|
274
|
+
if (!canonical) {
|
|
275
|
+
return next();
|
|
276
|
+
}
|
|
277
|
+
req.params.uri = canonical;
|
|
278
|
+
try {
|
|
279
|
+
const result = (await next());
|
|
280
|
+
for (const content of result.contents ?? []) {
|
|
281
|
+
if (typeof content.uri === "string" &&
|
|
282
|
+
stripQuery(content.uri) === stripQuery(canonical)) {
|
|
283
|
+
content.uri = requested;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
return result;
|
|
287
|
+
}
|
|
288
|
+
finally {
|
|
289
|
+
// Restore the shared request params so middleware outer to us never
|
|
290
|
+
// observes the rewritten lookup URI after next() unwinds.
|
|
291
|
+
req.params.uri = requested;
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
};
|
|
295
|
+
// ChatGPT reads `securitySchemes` at the tool descriptor top level (SEP-1488,
|
|
296
|
+
// still Draft), but the SDK's registerTool strips unknown top-level fields, so
|
|
297
|
+
// it's stashed in `_meta` at registration. This restores it to the top level
|
|
298
|
+
// on tools/list output. Remove once SEP-1488 lands and the SDK preserves it.
|
|
299
|
+
// { name: "checkout", _meta: { securitySchemes: [{ type: "oauth2" }] } }
|
|
300
|
+
// -> { name: "checkout", _meta: {…}, securitySchemes: [{ type: "oauth2" }] }
|
|
301
|
+
const toolsListSecuritySchemesEntry = {
|
|
302
|
+
filter: "tools/list",
|
|
303
|
+
handler: async (_req, _extra, next) => {
|
|
304
|
+
const result = (await next());
|
|
305
|
+
for (const tool of result.tools) {
|
|
306
|
+
const schemes = tool._meta?.securitySchemes;
|
|
307
|
+
if (schemes && !("securitySchemes" in tool)) {
|
|
308
|
+
tool.securitySchemes = schemes;
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
return result;
|
|
312
|
+
},
|
|
313
|
+
};
|
|
314
|
+
return [
|
|
315
|
+
viewListMetaEntry,
|
|
316
|
+
viewReadResolveEntry,
|
|
317
|
+
toolsListSecuritySchemesEntry,
|
|
318
|
+
...this.userMiddlewareEntries,
|
|
319
|
+
];
|
|
136
320
|
}
|
|
137
321
|
enforceOneToolPerView(component, toolName) {
|
|
138
322
|
const existingTool = this.claimedViews.get(component);
|
|
@@ -141,188 +325,168 @@ export class McpServer extends McpServerBaseOmitted {
|
|
|
141
325
|
}
|
|
142
326
|
this.claimedViews.set(component, toolName);
|
|
143
327
|
}
|
|
144
|
-
|
|
145
|
-
const
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
};
|
|
160
|
-
const fromView = {
|
|
161
|
-
"openai/widgetCSP": {
|
|
162
|
-
resource_domains: view.csp?.resourceDomains,
|
|
163
|
-
connect_domains: view.csp?.connectDomains,
|
|
164
|
-
frame_domains: view.csp?.frameDomains,
|
|
165
|
-
redirect_domains: view.csp?.redirectDomains,
|
|
166
|
-
},
|
|
167
|
-
"openai/widgetDomain": view.domain,
|
|
168
|
-
"openai/widgetPrefersBorder": view.prefersBorder,
|
|
169
|
-
};
|
|
170
|
-
const base = mergeWithUnion(mergeWithUnion(defaults, fromView), {
|
|
171
|
-
"openai/widgetDomain": overrides.domain,
|
|
172
|
-
});
|
|
173
|
-
if (view._meta) {
|
|
174
|
-
return { ...base, ...view._meta };
|
|
175
|
-
}
|
|
176
|
-
return base;
|
|
177
|
-
},
|
|
178
|
-
};
|
|
179
|
-
this.registerViewResource({
|
|
180
|
-
name: toolName,
|
|
181
|
-
viewResource,
|
|
182
|
-
view,
|
|
183
|
-
});
|
|
184
|
-
toolMeta["openai/outputTemplate"] = viewResource.uri;
|
|
328
|
+
resolveViewRequestContext(ctx) {
|
|
329
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
330
|
+
const header = (key) => ctx?.http?.req?.headers.get(key) ?? undefined;
|
|
331
|
+
const isClaude = hostFromUserAgent(header("user-agent")) === "claude";
|
|
332
|
+
const serverUrl = resolveServerOrigin(header);
|
|
333
|
+
// Path prefix the proxy routed this request under (e.g. `foo.com/v1`). Read
|
|
334
|
+
// per-request so one process can serve many hosts/prefixes at once: the
|
|
335
|
+
// origin is recovered from x-forwarded-host, the prefix from
|
|
336
|
+
// x-forwarded-prefix. Empty when served at the origin root.
|
|
337
|
+
const assetsBasePath = normalizeForwardedPrefix(header("x-forwarded-prefix"));
|
|
338
|
+
const connectDomains = [serverUrl];
|
|
339
|
+
if (!isProduction) {
|
|
340
|
+
const wsUrl = new URL(serverUrl);
|
|
341
|
+
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
342
|
+
connectDomains.push(wsUrl.origin);
|
|
185
343
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
344
|
+
let contentMetaOverrides = {};
|
|
345
|
+
if (isClaude) {
|
|
346
|
+
const pathname = ctx?.http?.req ? new URL(ctx.http.req.url).pathname : "";
|
|
347
|
+
const rawUrl = header("x-alpic-forwarded-url") ?? `${serverUrl}${pathname}`;
|
|
348
|
+
// Strip a lone trailing slash so the hash matches the connector URL
|
|
349
|
+
// as registered with Claude (which has no trailing slash on bare origins).
|
|
350
|
+
const url = rawUrl.endsWith("/") ? rawUrl.slice(0, -1) : rawUrl;
|
|
351
|
+
const hash = crypto
|
|
352
|
+
.createHash("sha256")
|
|
353
|
+
.update(url)
|
|
354
|
+
.digest("hex")
|
|
355
|
+
.slice(0, 32);
|
|
356
|
+
contentMetaOverrides = { domain: `${hash}.claudemcpcontent.com` };
|
|
357
|
+
}
|
|
358
|
+
return { serverUrl, assetsBasePath, connectDomains, contentMetaOverrides };
|
|
359
|
+
}
|
|
360
|
+
registerViewResources(toolName, view, toolMeta) {
|
|
361
|
+
// Append a content-derived version param so hosts (e.g. ChatGPT) bust
|
|
362
|
+
// their cache when the bundle changes, but keep the URI stable across
|
|
363
|
+
// `tools/list` calls when the bundle hasn't changed.
|
|
364
|
+
const versionParam = this.computeViewVersionParam(view.component);
|
|
365
|
+
const viewResource = {
|
|
366
|
+
uri: `ui://views/ext-apps/${view.component}.html${versionParam}`,
|
|
367
|
+
mimeType: "text/html;profile=mcp-app",
|
|
368
|
+
buildContentMeta: ({ resourceDomains, connectDomains, domain, baseUriDomains }, overrides) => {
|
|
369
|
+
const defaults = {
|
|
370
|
+
ui: {
|
|
371
|
+
csp: {
|
|
372
|
+
resourceDomains,
|
|
373
|
+
connectDomains,
|
|
374
|
+
baseUriDomains,
|
|
200
375
|
},
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
376
|
+
domain,
|
|
377
|
+
},
|
|
378
|
+
};
|
|
379
|
+
const fromView = {
|
|
380
|
+
ui: {
|
|
381
|
+
...(view.description && { description: view.description }),
|
|
382
|
+
...(view.prefersBorder !== undefined && {
|
|
383
|
+
prefersBorder: view.prefersBorder,
|
|
384
|
+
}),
|
|
385
|
+
...(view.domain && { domain: view.domain }),
|
|
386
|
+
csp: {
|
|
387
|
+
...(view.csp?.resourceDomains && {
|
|
388
|
+
resourceDomains: view.csp.resourceDomains,
|
|
389
|
+
}),
|
|
390
|
+
...(view.csp?.connectDomains && {
|
|
391
|
+
connectDomains: view.csp.connectDomains,
|
|
392
|
+
}),
|
|
393
|
+
...(view.csp?.frameDomains && {
|
|
394
|
+
frameDomains: view.csp.frameDomains,
|
|
395
|
+
}),
|
|
396
|
+
...(view.csp?.baseUriDomains && {
|
|
397
|
+
baseUriDomains: view.csp.baseUriDomains,
|
|
207
398
|
}),
|
|
208
|
-
...(view.domain && { domain: view.domain }),
|
|
209
|
-
csp: {
|
|
210
|
-
...(view.csp?.resourceDomains && {
|
|
211
|
-
resourceDomains: view.csp.resourceDomains,
|
|
212
|
-
}),
|
|
213
|
-
...(view.csp?.connectDomains && {
|
|
214
|
-
connectDomains: view.csp.connectDomains,
|
|
215
|
-
}),
|
|
216
|
-
...(view.csp?.frameDomains && {
|
|
217
|
-
frameDomains: view.csp.frameDomains,
|
|
218
|
-
}),
|
|
219
|
-
...(view.csp?.baseUriDomains && {
|
|
220
|
-
baseUriDomains: view.csp.baseUriDomains,
|
|
221
|
-
}),
|
|
222
|
-
...(view.csp?.redirectDomains && {
|
|
223
|
-
redirectDomains: view.csp.redirectDomains,
|
|
224
|
-
}),
|
|
225
|
-
},
|
|
226
399
|
},
|
|
227
|
-
}
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
400
|
+
},
|
|
401
|
+
};
|
|
402
|
+
const ui = mergeWithUnion(mergeWithUnion(defaults, fromView), {
|
|
403
|
+
ui: overrides,
|
|
404
|
+
});
|
|
405
|
+
const base = {
|
|
406
|
+
...ui,
|
|
407
|
+
...(view.description && {
|
|
408
|
+
"openai/widgetDescription": view.description,
|
|
409
|
+
}),
|
|
410
|
+
...(view.csp?.redirectDomains && {
|
|
411
|
+
"openai/widgetCSP": { redirect_domains: view.csp.redirectDomains },
|
|
412
|
+
}),
|
|
413
|
+
};
|
|
414
|
+
if (view._meta) {
|
|
415
|
+
return { ...base, ...view._meta };
|
|
416
|
+
}
|
|
417
|
+
return base;
|
|
418
|
+
},
|
|
419
|
+
};
|
|
420
|
+
this.registerViewResource({ name: toolName, viewResource, view });
|
|
421
|
+
// Advertise via the MCP Apps standard pointer only — ChatGPT renders from
|
|
422
|
+
// ui.resourceUri (verified), and not emitting openai/outputTemplate lets us
|
|
423
|
+
// retire the legacy apps-sdk resource later. The legacy apps-sdk URL is still
|
|
424
|
+
// served (see registerViewResource) so already-published apps keep resolving.
|
|
425
|
+
// @ts-expect-error - For backwards compatibility with Claude current implementation of the specs
|
|
426
|
+
toolMeta["ui/resourceUri"] = viewResource.uri;
|
|
427
|
+
toolMeta.ui = { ...toolMeta.ui, resourceUri: viewResource.uri };
|
|
246
428
|
}
|
|
247
429
|
registerViewResource({ name, viewResource, view, }) {
|
|
248
|
-
const {
|
|
430
|
+
const { uri: viewUri, mimeType, buildContentMeta } = viewResource;
|
|
431
|
+
const buildMeta = (extra) => {
|
|
432
|
+
const { serverUrl, connectDomains, contentMetaOverrides } = this.resolveViewRequestContext(extra);
|
|
433
|
+
return buildContentMeta({
|
|
434
|
+
resourceDomains: [serverUrl],
|
|
435
|
+
connectDomains,
|
|
436
|
+
domain: serverUrl,
|
|
437
|
+
baseUriDomains: [serverUrl],
|
|
438
|
+
}, contentMetaOverrides);
|
|
439
|
+
};
|
|
440
|
+
this.viewMetaBuilders.set(viewUri, buildMeta);
|
|
441
|
+
this.viewUriByPath.set(stripQuery(viewUri), viewUri);
|
|
442
|
+
this.serveLegacyAppsSdkUrl(view.component, viewUri);
|
|
249
443
|
this.registerResource(name, viewUri, { description: view.description }, async (uri, extra) => {
|
|
250
444
|
const isProduction = process.env.NODE_ENV === "production";
|
|
251
|
-
const
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
};
|
|
257
|
-
let serverUrl;
|
|
258
|
-
const forwardedHost = header("x-forwarded-host");
|
|
259
|
-
const origin = header("origin");
|
|
260
|
-
const host = header("host");
|
|
261
|
-
if (forwardedHost) {
|
|
262
|
-
const proto = header("x-forwarded-proto") || "https";
|
|
263
|
-
serverUrl = `${proto}://${forwardedHost}`;
|
|
264
|
-
}
|
|
265
|
-
else if (origin) {
|
|
266
|
-
serverUrl = origin;
|
|
267
|
-
}
|
|
268
|
-
else if (host) {
|
|
269
|
-
const proto = ["127.0.0.1:", "localhost:"].some((p) => host.startsWith(p))
|
|
270
|
-
? "http"
|
|
271
|
-
: "https";
|
|
272
|
-
serverUrl = `${proto}://${host}`;
|
|
273
|
-
}
|
|
274
|
-
else {
|
|
275
|
-
const devPort = process.env.__PORT || "3000";
|
|
276
|
-
serverUrl = `http://localhost:${devPort}`;
|
|
277
|
-
}
|
|
445
|
+
const { serverUrl, assetsBasePath } = this.resolveViewRequestContext(extra);
|
|
446
|
+
// The view resolves all assets (template imports + runtime lazy chunks
|
|
447
|
+
// via `window.skybridge.serverUrl`) against this base, so it carries the
|
|
448
|
+
// proxy path prefix. CSP domains in `buildMeta` stay the bare origin.
|
|
449
|
+
const viewBase = `${serverUrl}${assetsBasePath}`;
|
|
278
450
|
const html = isProduction
|
|
279
451
|
? templateHelper.renderProduction({
|
|
280
|
-
|
|
281
|
-
serverUrl,
|
|
452
|
+
serverUrl: viewBase,
|
|
282
453
|
viewFile: this.lookupViewFile(view.component),
|
|
283
454
|
styleFile: this.lookupDistFile("style.css") ?? "",
|
|
284
455
|
})
|
|
285
456
|
: templateHelper.renderDevelopment({
|
|
286
|
-
|
|
287
|
-
serverUrl,
|
|
457
|
+
serverUrl: viewBase,
|
|
288
458
|
viewName: view.component,
|
|
289
459
|
});
|
|
290
|
-
const connectDomains = [serverUrl];
|
|
291
|
-
if (!isProduction) {
|
|
292
|
-
const wsUrl = new URL(serverUrl);
|
|
293
|
-
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
294
|
-
connectDomains.push(wsUrl.origin);
|
|
295
|
-
}
|
|
296
|
-
let contentMetaOverrides = {};
|
|
297
|
-
if (isClaude) {
|
|
298
|
-
const pathname = extra?.requestInfo?.url?.pathname ?? "";
|
|
299
|
-
const rawUrl = header("x-alpic-forwarded-url") ?? `${serverUrl}${pathname}`;
|
|
300
|
-
// Strip a lone trailing slash so the hash matches the connector URL
|
|
301
|
-
// as registered with Claude (which has no trailing slash on bare origins).
|
|
302
|
-
const url = rawUrl.endsWith("/") ? rawUrl.slice(0, -1) : rawUrl;
|
|
303
|
-
const hash = crypto
|
|
304
|
-
.createHash("sha256")
|
|
305
|
-
.update(url)
|
|
306
|
-
.digest("hex")
|
|
307
|
-
.slice(0, 32);
|
|
308
|
-
contentMetaOverrides = { domain: `${hash}.claudemcpcontent.com` };
|
|
309
|
-
}
|
|
310
|
-
const contentMeta = buildContentMeta({
|
|
311
|
-
resourceDomains: [serverUrl],
|
|
312
|
-
connectDomains,
|
|
313
|
-
domain: serverUrl,
|
|
314
|
-
baseUriDomains: [serverUrl],
|
|
315
|
-
}, contentMetaOverrides);
|
|
316
460
|
return {
|
|
317
461
|
contents: [
|
|
318
|
-
{ uri: uri.href, mimeType, text: html, _meta:
|
|
462
|
+
{ uri: uri.href, mimeType, text: html, _meta: buildMeta(extra) },
|
|
319
463
|
],
|
|
320
464
|
};
|
|
321
465
|
});
|
|
322
466
|
}
|
|
323
|
-
|
|
467
|
+
serveLegacyAppsSdkUrl(component, canonicalUri) {
|
|
468
|
+
this.viewUriByPath.set(`ui://views/apps-sdk/${component}.html`, canonicalUri);
|
|
469
|
+
this.viewUriByPath.set(`ui://widgets/apps-sdk/${component}.html`, canonicalUri);
|
|
470
|
+
this.viewUriByPath.set(`ui://widgets/ext-apps/${component}.html`, canonicalUri);
|
|
471
|
+
}
|
|
472
|
+
decorateToolHandler(cb, { attachViewUUID, securitySchemes, toolName, }) {
|
|
324
473
|
return async (args, extra) => {
|
|
325
|
-
|
|
474
|
+
if (this.oauthEnabled) {
|
|
475
|
+
const failure = evaluateSecuritySchemes(securitySchemes, extra.http?.authInfo);
|
|
476
|
+
if (failure) {
|
|
477
|
+
const header = (key) => extra.http?.req?.headers.get(key) ?? undefined;
|
|
478
|
+
return inBandChallengeResult(failure, this.resolveResourceMetadataUrl?.(header));
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
let result;
|
|
482
|
+
try {
|
|
483
|
+
result = await cb(args, extra);
|
|
484
|
+
}
|
|
485
|
+
catch (error) {
|
|
486
|
+
captureToolError(extra, error);
|
|
487
|
+
throw error;
|
|
488
|
+
}
|
|
489
|
+
warnOnLargeToolOutput(result, toolName);
|
|
326
490
|
return {
|
|
327
491
|
...result,
|
|
328
492
|
content: normalizeContent(result.content),
|
|
@@ -335,6 +499,26 @@ export class McpServer extends McpServerBaseOmitted {
|
|
|
335
499
|
};
|
|
336
500
|
};
|
|
337
501
|
}
|
|
502
|
+
computeViewVersionParam(viewName) {
|
|
503
|
+
if (process.env.NODE_ENV !== "production") {
|
|
504
|
+
return "";
|
|
505
|
+
}
|
|
506
|
+
try {
|
|
507
|
+
const viewFile = this.lookupViewFile(viewName);
|
|
508
|
+
const styleFile = this.lookupDistFile("style.css") ?? "";
|
|
509
|
+
const hash = crypto
|
|
510
|
+
.createHash("sha256")
|
|
511
|
+
.update(viewFile)
|
|
512
|
+
.update("\0")
|
|
513
|
+
.update(styleFile)
|
|
514
|
+
.digest("hex")
|
|
515
|
+
.slice(0, 8);
|
|
516
|
+
return `?v=${hash}`;
|
|
517
|
+
}
|
|
518
|
+
catch {
|
|
519
|
+
return "";
|
|
520
|
+
}
|
|
521
|
+
}
|
|
338
522
|
lookupViewFile(viewName) {
|
|
339
523
|
const manifest = this.readManifest();
|
|
340
524
|
for (const entry of Object.values(manifest)) {
|
|
@@ -348,25 +532,59 @@ export class McpServer extends McpServerBaseOmitted {
|
|
|
348
532
|
const manifest = this.readManifest();
|
|
349
533
|
return manifest[key]?.file;
|
|
350
534
|
}
|
|
535
|
+
/**
|
|
536
|
+
* Inject the Vite manifest as a value rather than letting `readManifest()`
|
|
537
|
+
* load it from disk. Required for runtimes without a usable filesystem
|
|
538
|
+
* (Cloudflare Workers, etc.) — the user's `skybridge build` emits the
|
|
539
|
+
* manifest as a JS module which the entry imports and passes here.
|
|
540
|
+
*/
|
|
541
|
+
setViteManifest(manifest) {
|
|
542
|
+
this.viteManifest = manifest;
|
|
543
|
+
return this;
|
|
544
|
+
}
|
|
351
545
|
readManifest() {
|
|
352
|
-
|
|
546
|
+
if (this.viteManifest) {
|
|
547
|
+
return this.viteManifest;
|
|
548
|
+
}
|
|
549
|
+
cachedDiskManifest ??= JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
550
|
+
return cachedDiskManifest ?? {};
|
|
353
551
|
}
|
|
354
|
-
registerTool(
|
|
552
|
+
registerTool(rawConfig, rawCb) {
|
|
355
553
|
const baseFn = McpServerBase.prototype.registerTool;
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
554
|
+
const config = rawConfig;
|
|
555
|
+
const cb = rawCb;
|
|
556
|
+
const { name, view, auth, securitySchemes: rawSecuritySchemes, _meta: userToolMeta, ...toolFields } = config;
|
|
557
|
+
const authNeedsProvider = auth !== undefined &&
|
|
558
|
+
(!auth.allowsAnonymous || Boolean(auth.scopes?.length));
|
|
559
|
+
if (rawSecuritySchemes === undefined &&
|
|
560
|
+
authNeedsProvider &&
|
|
561
|
+
!this.oauthEnabled) {
|
|
562
|
+
throw new Error(`Tool "${name}" sets \`auth: ${JSON.stringify(auth)}\` but the server has no \`oauth\` provider configured.`);
|
|
359
563
|
}
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
const { name, view, _meta: userToolMeta, ...toolFields } = config;
|
|
564
|
+
const securitySchemes = rawSecuritySchemes ??
|
|
565
|
+
(auth && this.oauthEnabled ? authToSecuritySchemes(auth) : undefined);
|
|
363
566
|
const toolMeta = { ...userToolMeta };
|
|
567
|
+
this.toolSecuritySchemes.set(name, securitySchemes);
|
|
568
|
+
if (securitySchemes) {
|
|
569
|
+
// SEP-1488 puts `securitySchemes` at the top level of the tool
|
|
570
|
+
// descriptor, but the SDK's `registerTool` drops unknown top-level
|
|
571
|
+
// fields, so the canonical spot isn't reachable without intercepting
|
|
572
|
+
// `tools/list`. Use the `_meta` back-compat mirror documented in the
|
|
573
|
+
// Apps SDK reference until SEP-1488 lands in the spec.
|
|
574
|
+
toolMeta.securitySchemes = securitySchemes;
|
|
575
|
+
}
|
|
364
576
|
if (view) {
|
|
365
577
|
this.enforceOneToolPerView(view.component, name);
|
|
366
578
|
this.registerViewResources(name, view, toolMeta);
|
|
367
579
|
}
|
|
368
|
-
const wrappedCb = this.
|
|
369
|
-
|
|
580
|
+
const wrappedCb = this.decorateToolHandler(cb, {
|
|
581
|
+
attachViewUUID: Boolean(view),
|
|
582
|
+
securitySchemes,
|
|
583
|
+
toolName: name,
|
|
584
|
+
});
|
|
585
|
+
baseFn.call(this, name, { ...toolFields, _meta: toolMeta }, toolFields.inputSchema === undefined
|
|
586
|
+
? (extra) => wrappedCb({}, extra)
|
|
587
|
+
: wrappedCb);
|
|
370
588
|
return this;
|
|
371
589
|
}
|
|
372
590
|
}
|