skybridge 0.0.0-dev.efbdb09 → 0.0.0-dev.efe5a46
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 +124 -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.d.ts +1 -0
- package/dist/cli/build-helpers.test.js +130 -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.d.ts +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 +9 -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.d.ts +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.d.ts +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.d.ts +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.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 +72 -52
- 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 +8 -2
- package/dist/cli/use-typescript-check.js +71 -68
- 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/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 +32 -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 +18 -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 +18 -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 +48 -0
- package/dist/server/auth/providers/auth0.test.js.map +1 -0
- package/dist/server/auth/providers/clerk.d.ts +14 -0
- package/dist/server/auth/providers/clerk.js +16 -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 +28 -0
- package/dist/server/auth/providers/clerk.test.js.map +1 -0
- package/dist/server/auth/providers/custom.d.ts +32 -0
- package/dist/server/auth/providers/custom.js +49 -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 +156 -0
- package/dist/server/auth/providers/custom.test.js.map +1 -0
- package/dist/server/auth/providers/descope.d.ts +15 -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 +60 -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 +12 -0
- package/dist/server/auth/providers/stytch.js +13 -0
- package/dist/server/auth/providers/stytch.js.map +1 -0
- package/dist/server/auth/providers/workos.d.ts +11 -0
- package/dist/server/auth/providers/workos.js +12 -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 +92 -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 +474 -0
- package/dist/server/auth/setup.test.js.map +1 -0
- package/dist/server/auth/verify.d.ts +12 -0
- package/dist/server/auth/verify.js +38 -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 +100 -0
- package/dist/server/auth/verify.test.js.map +1 -0
- package/dist/server/auth.d.ts +20 -0
- package/dist/server/auth.js +28 -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 +27 -0
- package/dist/server/build-manifest.test.js.map +1 -0
- package/dist/server/content-helpers.d.ts +40 -0
- 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 +1 -5
- package/dist/server/express.js +31 -7
- package/dist/server/express.js.map +1 -1
- package/dist/server/express.test.js +271 -69
- package/dist/server/express.test.js.map +1 -1
- 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 +12 -2
- package/dist/server/index.js +10 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/inferUtilityTypes.js.map +1 -1
- package/dist/server/metric.js.map +1 -1
- package/dist/server/middleware.d.ts +16 -3
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/middleware.test-d.js.map +1 -1
- package/dist/server/middleware.test.js.map +1 -1
- 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 +292 -10
- package/dist/server/server.js +479 -184
- 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 +63 -0
- package/dist/server/skills-integration.test.js.map +1 -0
- package/dist/server/skills.d.ts +23 -0
- package/dist/server/skills.js +178 -0
- package/dist/server/skills.js.map +1 -0
- package/dist/server/skills.test.d.ts +1 -0
- package/dist/server/skills.test.js +210 -0
- package/dist/server/skills.test.js.map +1 -0
- package/dist/server/templateHelper.d.ts +0 -2
- 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 +47 -0
- package/dist/server/templates.generated.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 +171 -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.js.map +1 -1
- package/dist/test/view.test.js +109 -96
- package/dist/test/view.test.js.map +1 -1
- package/dist/version.js +1 -3
- package/dist/version.js.map +1 -1
- package/dist/web/bridges/adaptor.d.ts +51 -0
- package/dist/web/bridges/adaptor.js +330 -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 +208 -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.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 +108 -3
- 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 +26 -0
- package/dist/web/create-store.js.map +1 -1
- package/dist/web/create-store.test.js +8 -5
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.d.ts +34 -1
- package/dist/web/data-llm.js +28 -0
- package/dist/web/data-llm.js.map +1 -1
- package/dist/web/data-llm.test.js +17 -5
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +2 -0
- package/dist/web/generate-helpers.js +2 -0
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/generate-helpers.test-d.js +4 -2
- package/dist/web/generate-helpers.test-d.js.map +1 -1
- package/dist/web/generate-helpers.test.js.map +1 -1
- package/dist/web/helpers/state.js.map +1 -1
- package/dist/web/helpers/state.test.js.map +1 -1
- package/dist/web/hooks/index.d.ts +5 -0
- package/dist/web/hooks/index.js +5 -0
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/test/utils.d.ts +6 -2
- package/dist/web/hooks/test/utils.js +13 -2
- 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 +62 -27
- 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 +56 -20
- package/dist/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/web/hooks/use-download.d.ts +5 -0
- package/dist/web/hooks/use-download.js +8 -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 +10 -2
- package/dist/web/hooks/use-files.test.js.map +1 -1
- package/dist/web/hooks/use-host-info.d.ts +22 -0
- package/dist/web/hooks/use-host-info.js +30 -0
- package/dist/web/hooks/use-host-info.js.map +1 -0
- package/dist/web/hooks/use-layout.d.ts +2 -0
- package/dist/web/hooks/use-layout.js +2 -0
- package/dist/web/hooks/use-layout.js.map +1 -1
- package/dist/web/hooks/use-layout.test.js +59 -26
- package/dist/web/hooks/use-layout.test.js.map +1 -1
- 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 +13 -3
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-register-view-tool.d.ts +38 -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 +16 -1
- package/dist/web/hooks/use-request-modal.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js +10 -0
- 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 +28 -8
- package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
- package/dist/web/hooks/use-tool-info.d.ts +53 -2
- package/dist/web/hooks/use-tool-info.js +30 -7
- package/dist/web/hooks/use-tool-info.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test-d.js +11 -29
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +42 -32
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.d.ts +2 -0
- package/dist/web/hooks/use-user.js +2 -0
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +81 -35
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/dist/web/hooks/use-view-state.d.ts +21 -0
- package/dist/web/hooks/use-view-state.js.map +1 -1
- package/dist/web/hooks/use-view-state.test.js +6 -2
- package/dist/web/hooks/use-view-state.test.js.map +1 -1
- package/dist/web/index.js.map +1 -1
- package/dist/web/mount-view.d.ts +19 -0
- package/dist/web/mount-view.js +19 -0
- package/dist/web/mount-view.js.map +1 -1
- package/dist/web/plugin/data-llm.test.js.map +1 -1
- package/dist/web/plugin/plugin.d.ts +34 -0
- package/dist/web/plugin/plugin.js +65 -17
- package/dist/web/plugin/plugin.js.map +1 -1
- package/dist/web/plugin/scan-views.d.ts +8 -0
- package/dist/web/plugin/scan-views.js +26 -8
- package/dist/web/plugin/scan-views.js.map +1 -1
- package/dist/web/plugin/scan-views.test.js +33 -1
- package/dist/web/plugin/scan-views.test.js.map +1 -1
- package/dist/web/plugin/transform-data-llm.js.map +1 -1
- package/dist/web/plugin/transform-data-llm.test.js.map +1 -1
- package/dist/web/plugin/validate-view.js.map +1 -1
- package/dist/web/plugin/validate-view.test.js.map +1 -1
- 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 +34 -24
- 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 -93
- 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/server/server.js
CHANGED
|
@@ -5,9 +5,15 @@ import path from "node:path";
|
|
|
5
5
|
import { Server as SdkServer, } from "@modelcontextprotocol/sdk/server/index.js";
|
|
6
6
|
import { McpServer as McpServerBase } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
7
|
import { mergeWith, union } from "es-toolkit";
|
|
8
|
+
import express, {} from "express";
|
|
9
|
+
import { authToSecuritySchemes, evaluateSecuritySchemes, inBandChallengeResult, } from "./auth/security-schemes.js";
|
|
10
|
+
import { setupOAuth } from "./auth/setup.js";
|
|
8
11
|
import { createApp } from "./express.js";
|
|
12
|
+
import { hostFromUserAgent } from "./host.js";
|
|
9
13
|
import { createMiddlewareEntry } from "./metric.js";
|
|
10
14
|
import { buildMiddlewareChain, getHandlerMaps } from "./middleware.js";
|
|
15
|
+
import { resolveServerOrigin } from "./requestOrigin.js";
|
|
16
|
+
import { discoverSkills, registerSkills, SKILLS_EXTENSION_KEY, } from "./skills.js";
|
|
11
17
|
import { templateHelper } from "./templateHelper.js";
|
|
12
18
|
const mergeWithUnion = (target, source) => {
|
|
13
19
|
return mergeWith(target, source, (targetVal, sourceVal) => {
|
|
@@ -16,6 +22,35 @@ const mergeWithUnion = (target, source) => {
|
|
|
16
22
|
}
|
|
17
23
|
});
|
|
18
24
|
};
|
|
25
|
+
const SKILLS_DIR = "src/skills";
|
|
26
|
+
/**
|
|
27
|
+
* Normalize an `x-forwarded-prefix` value into a leading-slash, no-trailing-slash
|
|
28
|
+
* path. Takes the first hop of a comma-separated proxy chain.
|
|
29
|
+
* "/v1/", "v1", "/v1, /internal" → "/v1"; "", "/", undefined → "".
|
|
30
|
+
*/
|
|
31
|
+
function normalizeForwardedPrefix(raw) {
|
|
32
|
+
const firstHop = raw?.split(",")[0]?.trim() ?? "";
|
|
33
|
+
const trimmed = firstHop.replace(/\/+$/, "");
|
|
34
|
+
if (trimmed === "") {
|
|
35
|
+
return "";
|
|
36
|
+
}
|
|
37
|
+
return trimmed.startsWith("/") ? trimmed : `/${trimmed}`;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Drop the query string from a `ui://` view URI, leaving the bare path. The
|
|
41
|
+
* `?v=` cache key is the only query we append, so a plain split is enough and
|
|
42
|
+
* sidesteps `URL` normalization quirks on the non-special `ui:` scheme.
|
|
43
|
+
*/
|
|
44
|
+
function stripQuery(uri) {
|
|
45
|
+
const queryIndex = uri.indexOf("?");
|
|
46
|
+
return queryIndex === -1 ? uri : uri.slice(0, queryIndex);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Coerce a tool handler's return value into an MCP `content` array. Strings
|
|
50
|
+
* become a single `TextContent`; a single block is wrapped in an array;
|
|
51
|
+
* `undefined` produces `[]`. Mostly used internally — exported so consumers
|
|
52
|
+
* who build content lazily can apply the same normalization.
|
|
53
|
+
*/
|
|
19
54
|
export function normalizeContent(content) {
|
|
20
55
|
if (content === undefined) {
|
|
21
56
|
return [];
|
|
@@ -29,31 +64,168 @@ export function normalizeContent(content) {
|
|
|
29
64
|
return [content];
|
|
30
65
|
}
|
|
31
66
|
const McpServerBaseOmitted = McpServerBase;
|
|
67
|
+
/**
|
|
68
|
+
* The Skybridge server. Extends the MCP SDK's `McpServer` with a typed tool
|
|
69
|
+
* registry, view resources, an embedded Express app, and protocol-level
|
|
70
|
+
* middleware. Construct it with the same `Implementation` info you would pass
|
|
71
|
+
* to the SDK, chain {@link McpServer.registerTool} calls to declare tools,
|
|
72
|
+
* then call {@link McpServer.run} to start the HTTP server.
|
|
73
|
+
*
|
|
74
|
+
* The `TTools` generic accumulates each registered tool's input/output/meta
|
|
75
|
+
* shape, so `typeof server` carries enough information for view-side helpers
|
|
76
|
+
* like {@link generateHelpers} to produce fully-typed hooks.
|
|
77
|
+
*
|
|
78
|
+
* @typeParam TTools - Accumulated tool registry. Filled in by `registerTool`
|
|
79
|
+
* chaining; you almost never set this manually.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* ```ts
|
|
83
|
+
* const server = new McpServer({ name: "my-app", version: "1.0.0" }, {})
|
|
84
|
+
* .registerTool({
|
|
85
|
+
* name: "search",
|
|
86
|
+
* inputSchema: { query: z.string() },
|
|
87
|
+
* view: { component: "search" },
|
|
88
|
+
* }, async ({ query }) => ({ content: `Results for ${query}` }));
|
|
89
|
+
*
|
|
90
|
+
* await server.run();
|
|
91
|
+
* export type AppType = typeof server;
|
|
92
|
+
* ```
|
|
93
|
+
*
|
|
94
|
+
* @see https://docs.skybridge.tech/api-reference/mcp-server
|
|
95
|
+
*/
|
|
96
|
+
// Side channel populated by `dist/__entry.js` before user code is imported.
|
|
97
|
+
// Set at module scope rather than passed through the constructor because the
|
|
98
|
+
// wrapper has the manifest before the user's `new McpServer(...)` runs, and
|
|
99
|
+
// threading it through every call site (including user templates) is exactly
|
|
100
|
+
// the boilerplate this design is trying to hide.
|
|
101
|
+
let pendingBuildManifest = null;
|
|
102
|
+
/**
|
|
103
|
+
* Prime the build-time Vite manifest before user code constructs its
|
|
104
|
+
* `McpServer`. Called from the generated `dist/__entry.js`; not part of the
|
|
105
|
+
* user-facing API.
|
|
106
|
+
*
|
|
107
|
+
* @internal
|
|
108
|
+
*/
|
|
109
|
+
export function __setBuildManifest(manifest) {
|
|
110
|
+
pendingBuildManifest = manifest;
|
|
111
|
+
}
|
|
112
|
+
let pendingSkillsManifest = null;
|
|
113
|
+
export function __setSkillsManifest(manifest) {
|
|
114
|
+
pendingSkillsManifest = manifest;
|
|
115
|
+
}
|
|
116
|
+
// Pure and `this`-free so it can run inside the `super(...)` call, before `this`
|
|
117
|
+
// exists — the capability must be present for the `initialize` response.
|
|
118
|
+
function withSkillsCapability(options, skybridgeOptions) {
|
|
119
|
+
if (!skybridgeOptions?.skills) {
|
|
120
|
+
return options;
|
|
121
|
+
}
|
|
122
|
+
return {
|
|
123
|
+
...options,
|
|
124
|
+
capabilities: {
|
|
125
|
+
...options?.capabilities,
|
|
126
|
+
extensions: {
|
|
127
|
+
...options?.capabilities?.extensions,
|
|
128
|
+
[SKILLS_EXTENSION_KEY]: { directoryRead: true },
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
// Collapses registerTool's two overloads into a single { config, cb } shape.
|
|
134
|
+
// registerTool("greet", { description }, handler)
|
|
135
|
+
// -> { config: { name: "greet", description }, cb: handler }
|
|
136
|
+
// registerTool({ name: "greet", description }, handler)
|
|
137
|
+
// -> { config: { name: "greet", description }, cb: handler }
|
|
138
|
+
function normalizeRegisterToolArgs(args) {
|
|
139
|
+
if (typeof args[0] === "string") {
|
|
140
|
+
return {
|
|
141
|
+
config: {
|
|
142
|
+
name: args[0],
|
|
143
|
+
...args[1],
|
|
144
|
+
},
|
|
145
|
+
cb: args[2],
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
return {
|
|
149
|
+
config: args[0],
|
|
150
|
+
cb: args[1],
|
|
151
|
+
};
|
|
152
|
+
}
|
|
32
153
|
export class McpServer extends McpServerBaseOmitted {
|
|
154
|
+
/**
|
|
155
|
+
* The underlying Express app. Use this to extend the HTTP server with
|
|
156
|
+
* custom routes, middleware, or settings — e.g.
|
|
157
|
+
* `server.express.get("/health", ...)`.
|
|
158
|
+
*
|
|
159
|
+
* `express.json()` is pre-applied — tune it via the constructor's third
|
|
160
|
+
* argument, e.g. `new McpServer(info, {}, { json: { limit: "10mb" } })`.
|
|
161
|
+
* Register your handlers before `run()`;
|
|
162
|
+
* after `run()`, dev-mode middleware, the `/mcp` route, and the default
|
|
163
|
+
* error handler are appended in that order.
|
|
164
|
+
*
|
|
165
|
+
* Note: Alpic Cloud only routes traffic to `/mcp` — custom routes work
|
|
166
|
+
* locally and on self-hosted deployments.
|
|
167
|
+
*/
|
|
33
168
|
express;
|
|
34
|
-
customMiddleware = [];
|
|
35
169
|
customErrorMiddleware = [];
|
|
36
170
|
mcpMiddlewareEntries = [];
|
|
37
171
|
mcpMiddlewareApplied = false;
|
|
38
172
|
claimedViews = new Map();
|
|
173
|
+
viewMetaBuilders = new Map();
|
|
174
|
+
/**
|
|
175
|
+
* Maps a view resource's query-less path to its canonical registered URI
|
|
176
|
+
* (the one carrying the `?v=` cache key). Lets `resources/read` resolve the
|
|
177
|
+
* underlying view no matter which version param the consumer sends, since
|
|
178
|
+
* the param is only a cache key, not part of the resource's identity.
|
|
179
|
+
*/
|
|
180
|
+
viewUriByPath = new Map();
|
|
181
|
+
viteManifest = null;
|
|
39
182
|
serverInfo;
|
|
40
183
|
serverOptions;
|
|
41
|
-
|
|
42
|
-
|
|
184
|
+
oauthEnabled = false;
|
|
185
|
+
resolveResourceMetadataUrl;
|
|
186
|
+
securitySchemesByTool = new Map();
|
|
187
|
+
constructor(serverInfo, options, skybridgeOptions) {
|
|
188
|
+
const mergedOptions = withSkillsCapability(options, skybridgeOptions);
|
|
189
|
+
super(serverInfo, mergedOptions);
|
|
43
190
|
this.serverInfo = serverInfo;
|
|
44
|
-
this.serverOptions =
|
|
191
|
+
this.serverOptions = mergedOptions;
|
|
192
|
+
this.express = express();
|
|
193
|
+
this.express.use(express.json(skybridgeOptions?.json));
|
|
194
|
+
if (skybridgeOptions?.oauth) {
|
|
195
|
+
this.oauthEnabled = true;
|
|
196
|
+
this.resolveResourceMetadataUrl = setupOAuth(this.express, skybridgeOptions.oauth, this.securitySchemesByTool);
|
|
197
|
+
}
|
|
198
|
+
// Pick up the manifest if `dist/__entry.js` primed it before importing
|
|
199
|
+
// user code. Consume-once: clear after the first construction so a
|
|
200
|
+
// subsequent test that doesn't prime can't inherit stale state.
|
|
201
|
+
// Explicit `setViteManifest` calls still win because they happen after
|
|
202
|
+
// construction.
|
|
203
|
+
if (pendingBuildManifest) {
|
|
204
|
+
this.setViteManifest(pendingBuildManifest);
|
|
205
|
+
pendingBuildManifest = null;
|
|
206
|
+
}
|
|
207
|
+
this.setupSkills(Boolean(skybridgeOptions?.skills));
|
|
208
|
+
}
|
|
209
|
+
setupSkills(enabled) {
|
|
210
|
+
const manifest = pendingSkillsManifest;
|
|
211
|
+
pendingSkillsManifest = null;
|
|
212
|
+
if (!enabled) {
|
|
213
|
+
return;
|
|
214
|
+
}
|
|
215
|
+
const skills = manifest ?? discoverSkills(SKILLS_DIR);
|
|
216
|
+
if (skills.length === 0) {
|
|
217
|
+
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.`);
|
|
218
|
+
}
|
|
219
|
+
registerSkills(this, skills);
|
|
45
220
|
}
|
|
46
221
|
use(pathOrHandler, ...handlers) {
|
|
222
|
+
// Branching is load-bearing: Express's `app.use` overloads can't be
|
|
223
|
+
// resolved against a `string | RequestHandler` union, so we narrow.
|
|
47
224
|
if (typeof pathOrHandler === "string") {
|
|
48
|
-
this.
|
|
49
|
-
path: pathOrHandler,
|
|
50
|
-
handlers,
|
|
51
|
-
});
|
|
225
|
+
this.express.use(pathOrHandler, ...handlers);
|
|
52
226
|
}
|
|
53
227
|
else {
|
|
54
|
-
this.
|
|
55
|
-
handlers: [pathOrHandler, ...handlers],
|
|
56
|
-
});
|
|
228
|
+
this.express.use(pathOrHandler, ...handlers);
|
|
57
229
|
}
|
|
58
230
|
return this;
|
|
59
231
|
}
|
|
@@ -97,13 +269,89 @@ export class McpServer extends McpServerBaseOmitted {
|
|
|
97
269
|
return;
|
|
98
270
|
}
|
|
99
271
|
this.mcpMiddlewareApplied = true;
|
|
272
|
+
// Surface view-resource _meta on `resources/list` (per ext-apps spec:
|
|
273
|
+
// hosts/checkers read CSP & domain at list time before fetching content).
|
|
274
|
+
const viewListMetaEntry = {
|
|
275
|
+
filter: "resources/list",
|
|
276
|
+
handler: async (_req, extra, next) => {
|
|
277
|
+
const result = (await next());
|
|
278
|
+
for (const resource of result.resources) {
|
|
279
|
+
const builder = this.viewMetaBuilders.get(resource.uri);
|
|
280
|
+
if (!builder) {
|
|
281
|
+
continue;
|
|
282
|
+
}
|
|
283
|
+
const meta = builder(extra);
|
|
284
|
+
resource._meta = {
|
|
285
|
+
...(resource._meta ?? {}),
|
|
286
|
+
...meta,
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
return result;
|
|
290
|
+
},
|
|
291
|
+
};
|
|
292
|
+
// Resolve a view's `resources/read` by its query-less path so the
|
|
293
|
+
// underlying asset is served no matter the `?v=` value (stale cache key,
|
|
294
|
+
// no param, etc.). The version param is a cache-busting hint for external
|
|
295
|
+
// consumers; it must not gate resolution. We rewrite the lookup URI to the
|
|
296
|
+
// canonical registered one, then restore the requested URI on the response
|
|
297
|
+
// so the consumer-facing URI is never rewritten.
|
|
298
|
+
const viewReadResolveEntry = {
|
|
299
|
+
filter: "resources/read",
|
|
300
|
+
handler: async (req, _extra, next) => {
|
|
301
|
+
const requested = req.params.uri;
|
|
302
|
+
if (typeof requested !== "string") {
|
|
303
|
+
return next();
|
|
304
|
+
}
|
|
305
|
+
const path = stripQuery(requested);
|
|
306
|
+
const canonical = this.viewUriByPath.get(path);
|
|
307
|
+
if (!canonical) {
|
|
308
|
+
return next();
|
|
309
|
+
}
|
|
310
|
+
req.params.uri = canonical;
|
|
311
|
+
try {
|
|
312
|
+
const result = (await next());
|
|
313
|
+
for (const content of result.contents ?? []) {
|
|
314
|
+
if (typeof content.uri === "string" &&
|
|
315
|
+
stripQuery(content.uri) === stripQuery(canonical)) {
|
|
316
|
+
content.uri = requested;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
return result;
|
|
320
|
+
}
|
|
321
|
+
finally {
|
|
322
|
+
// Restore the shared request params so middleware outer to us never
|
|
323
|
+
// observes the rewritten lookup URI after next() unwinds.
|
|
324
|
+
req.params.uri = requested;
|
|
325
|
+
}
|
|
326
|
+
},
|
|
327
|
+
};
|
|
328
|
+
// ChatGPT reads `securitySchemes` at the tool descriptor top level (SEP-1488,
|
|
329
|
+
// still Draft), but the SDK's registerTool strips unknown top-level fields, so
|
|
330
|
+
// it's stashed in `_meta` at registration. This restores it to the top level
|
|
331
|
+
// on tools/list output. Remove once SEP-1488 lands and the SDK preserves it.
|
|
332
|
+
// { name: "checkout", _meta: { securitySchemes: [{ type: "oauth2" }] } }
|
|
333
|
+
// -> { name: "checkout", _meta: {…}, securitySchemes: [{ type: "oauth2" }] }
|
|
334
|
+
const toolsListSecuritySchemesEntry = {
|
|
335
|
+
filter: "tools/list",
|
|
336
|
+
handler: async (_req, _extra, next) => {
|
|
337
|
+
const result = (await next());
|
|
338
|
+
for (const tool of result.tools) {
|
|
339
|
+
const schemes = tool._meta?.securitySchemes;
|
|
340
|
+
if (schemes && !("securitySchemes" in tool)) {
|
|
341
|
+
tool.securitySchemes = schemes;
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
return result;
|
|
345
|
+
},
|
|
346
|
+
};
|
|
100
347
|
const monitoringEntry = createMiddlewareEntry();
|
|
101
|
-
const entries =
|
|
102
|
-
? [monitoringEntry
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
348
|
+
const entries = [
|
|
349
|
+
...(monitoringEntry ? [monitoringEntry] : []),
|
|
350
|
+
viewListMetaEntry,
|
|
351
|
+
viewReadResolveEntry,
|
|
352
|
+
toolsListSecuritySchemesEntry,
|
|
353
|
+
...this.mcpMiddlewareEntries,
|
|
354
|
+
];
|
|
107
355
|
const { requestHandlers, notificationHandlers } = getHandlerMaps(this.server);
|
|
108
356
|
const instrumentMap = (map, isNotification) => {
|
|
109
357
|
for (const [method, handler] of map) {
|
|
@@ -115,6 +363,14 @@ export class McpServer extends McpServerBaseOmitted {
|
|
|
115
363
|
instrumentMap(requestHandlers, false);
|
|
116
364
|
instrumentMap(notificationHandlers, true);
|
|
117
365
|
}
|
|
366
|
+
/**
|
|
367
|
+
* Connect to an MCP transport (override of the SDK's `connect`). Use this
|
|
368
|
+
* when you're embedding Skybridge in a host that already manages its own
|
|
369
|
+
* transport (e.g. stdio for desktop apps); for HTTP, prefer {@link McpServer.run}
|
|
370
|
+
* which sets the transport up for you. Locks in any middleware registered
|
|
371
|
+
* via {@link McpServer.mcpMiddleware} — further calls to that method will
|
|
372
|
+
* throw afterwards.
|
|
373
|
+
*/
|
|
118
374
|
async connect(transport) {
|
|
119
375
|
this.applyMcpMiddleware();
|
|
120
376
|
return McpServerBase.prototype.connect.call(this, transport);
|
|
@@ -138,28 +394,58 @@ export class McpServer extends McpServerBaseOmitted {
|
|
|
138
394
|
target._notificationHandlers = notificationHandlers;
|
|
139
395
|
await fresh.connect(transport);
|
|
140
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* Start the HTTP server. Listens on `process.env.__PORT` (default `3000`),
|
|
399
|
+
* mounts the `/mcp` route, applies any custom Express middleware registered
|
|
400
|
+
* via {@link McpServer.use} / {@link McpServer.useOnError}, and locks in
|
|
401
|
+
* any MCP middleware registered via {@link McpServer.mcpMiddleware}.
|
|
402
|
+
*
|
|
403
|
+
* On Cloudflare Workers / workerd, returns an object exposing `fetch` so
|
|
404
|
+
* the runtime can bridge incoming requests to the Node HTTP server. On
|
|
405
|
+
* Vercel (`VERCEL === "1"`), returns the Express app directly so the
|
|
406
|
+
* serverless function entry can call it as a `(req, res)` handler. On
|
|
407
|
+
* Node, returns `undefined` once listening.
|
|
408
|
+
*/
|
|
141
409
|
async run() {
|
|
142
410
|
this.applyMcpMiddleware();
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
411
|
+
if (process.env.VERCEL === "1") {
|
|
412
|
+
// createApp only reads httpServer inside its dev-only branch
|
|
413
|
+
// (viewsDevServer); under VERCEL=1 + NODE_ENV=production it's a
|
|
414
|
+
// bare object passed to satisfy the required parameter.
|
|
415
|
+
const httpServer = http.createServer();
|
|
416
|
+
await createApp({
|
|
146
417
|
mcpServer: this,
|
|
147
418
|
httpServer,
|
|
148
|
-
customMiddleware: this.customMiddleware,
|
|
149
419
|
errorMiddleware: this.customErrorMiddleware,
|
|
150
420
|
});
|
|
421
|
+
return this.express;
|
|
151
422
|
}
|
|
423
|
+
const httpServer = http.createServer();
|
|
424
|
+
await createApp({
|
|
425
|
+
mcpServer: this,
|
|
426
|
+
httpServer,
|
|
427
|
+
errorMiddleware: this.customErrorMiddleware,
|
|
428
|
+
});
|
|
152
429
|
httpServer.on("request", this.express);
|
|
430
|
+
const port = parseInt(process.env.__PORT ?? "3000", 10);
|
|
153
431
|
await new Promise((resolve, reject) => {
|
|
154
432
|
httpServer.on("error", (error) => {
|
|
155
433
|
console.error("Failed to start server:", error);
|
|
156
434
|
reject(error);
|
|
157
435
|
});
|
|
158
|
-
const port = parseInt(process.env.__PORT ?? "3000", 10);
|
|
159
436
|
httpServer.listen(port, () => {
|
|
160
437
|
resolve();
|
|
161
438
|
});
|
|
162
439
|
});
|
|
440
|
+
// On workerd, bridge the Node http server to a Workers fetch handler.
|
|
441
|
+
// The specifier is held in a variable to sidestep tsc's module resolution
|
|
442
|
+
// (`cloudflare:node` only exists under wrangler/workerd).
|
|
443
|
+
if (typeof navigator !== "undefined" &&
|
|
444
|
+
navigator.userAgent === "Cloudflare-Workers") {
|
|
445
|
+
const cloudflareNode = "cloudflare:node";
|
|
446
|
+
const { httpServerHandler } = await import(cloudflareNode);
|
|
447
|
+
return httpServerHandler({ port });
|
|
448
|
+
}
|
|
163
449
|
const shutdown = () => {
|
|
164
450
|
// Drop both handlers so a second signal falls through to Node's default
|
|
165
451
|
// (force-quit on a second Ctrl+C while drain is hanging).
|
|
@@ -172,6 +458,7 @@ export class McpServer extends McpServerBaseOmitted {
|
|
|
172
458
|
};
|
|
173
459
|
process.on("SIGTERM", shutdown);
|
|
174
460
|
process.on("SIGINT", shutdown);
|
|
461
|
+
return undefined;
|
|
175
462
|
}
|
|
176
463
|
enforceOneToolPerView(component, toolName) {
|
|
177
464
|
const existingTool = this.claimedViews.get(component);
|
|
@@ -180,191 +467,170 @@ export class McpServer extends McpServerBaseOmitted {
|
|
|
180
467
|
}
|
|
181
468
|
this.claimedViews.set(component, toolName);
|
|
182
469
|
}
|
|
470
|
+
resolveViewRequestContext(extra) {
|
|
471
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
472
|
+
const headers = extra?.requestInfo?.headers || {};
|
|
473
|
+
const header = (key) => {
|
|
474
|
+
const val = headers[key];
|
|
475
|
+
return Array.isArray(val) ? val[0] : val;
|
|
476
|
+
};
|
|
477
|
+
const isClaude = hostFromUserAgent(header("user-agent")) === "claude";
|
|
478
|
+
const serverUrl = resolveServerOrigin(header);
|
|
479
|
+
// Path prefix the proxy routed this request under (e.g. `foo.com/v1`). Read
|
|
480
|
+
// per-request so one process can serve many hosts/prefixes at once: the
|
|
481
|
+
// origin is recovered from x-forwarded-host, the prefix from
|
|
482
|
+
// x-forwarded-prefix. Empty when served at the origin root.
|
|
483
|
+
const assetsBasePath = normalizeForwardedPrefix(header("x-forwarded-prefix"));
|
|
484
|
+
const connectDomains = [serverUrl];
|
|
485
|
+
if (!isProduction) {
|
|
486
|
+
const wsUrl = new URL(serverUrl);
|
|
487
|
+
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
488
|
+
connectDomains.push(wsUrl.origin);
|
|
489
|
+
}
|
|
490
|
+
let contentMetaOverrides = {};
|
|
491
|
+
if (isClaude) {
|
|
492
|
+
const pathname = extra?.requestInfo?.url?.pathname ?? "";
|
|
493
|
+
const rawUrl = header("x-alpic-forwarded-url") ?? `${serverUrl}${pathname}`;
|
|
494
|
+
// Strip a lone trailing slash so the hash matches the connector URL
|
|
495
|
+
// as registered with Claude (which has no trailing slash on bare origins).
|
|
496
|
+
const url = rawUrl.endsWith("/") ? rawUrl.slice(0, -1) : rawUrl;
|
|
497
|
+
const hash = crypto
|
|
498
|
+
.createHash("sha256")
|
|
499
|
+
.update(url)
|
|
500
|
+
.digest("hex")
|
|
501
|
+
.slice(0, 32);
|
|
502
|
+
contentMetaOverrides = { domain: `${hash}.claudemcpcontent.com` };
|
|
503
|
+
}
|
|
504
|
+
return { serverUrl, assetsBasePath, connectDomains, contentMetaOverrides };
|
|
505
|
+
}
|
|
183
506
|
registerViewResources(toolName, view, toolMeta) {
|
|
184
|
-
const hosts = view.hosts ?? ["apps-sdk", "mcp-app"];
|
|
185
507
|
// Append a content-derived version param so hosts (e.g. ChatGPT) bust
|
|
186
508
|
// their cache when the bundle changes, but keep the URI stable across
|
|
187
509
|
// `tools/list` calls when the bundle hasn't changed.
|
|
188
510
|
const versionParam = this.computeViewVersionParam(view.component);
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
"openai/widgetDomain": domain,
|
|
201
|
-
"openai/widgetDescription": view.description,
|
|
202
|
-
};
|
|
203
|
-
const fromView = {
|
|
204
|
-
"openai/widgetCSP": {
|
|
205
|
-
resource_domains: view.csp?.resourceDomains,
|
|
206
|
-
connect_domains: view.csp?.connectDomains,
|
|
207
|
-
frame_domains: view.csp?.frameDomains,
|
|
208
|
-
redirect_domains: view.csp?.redirectDomains,
|
|
209
|
-
},
|
|
210
|
-
"openai/widgetDomain": view.domain,
|
|
211
|
-
"openai/widgetPrefersBorder": view.prefersBorder,
|
|
212
|
-
};
|
|
213
|
-
const base = mergeWithUnion(mergeWithUnion(defaults, fromView), {
|
|
214
|
-
"openai/widgetDomain": overrides.domain,
|
|
215
|
-
});
|
|
216
|
-
if (view._meta) {
|
|
217
|
-
return { ...base, ...view._meta };
|
|
218
|
-
}
|
|
219
|
-
return base;
|
|
220
|
-
},
|
|
221
|
-
};
|
|
222
|
-
this.registerViewResource({
|
|
223
|
-
name: toolName,
|
|
224
|
-
viewResource,
|
|
225
|
-
view,
|
|
226
|
-
});
|
|
227
|
-
toolMeta["openai/outputTemplate"] = viewResource.uri;
|
|
228
|
-
}
|
|
229
|
-
if (hosts.includes("mcp-app")) {
|
|
230
|
-
const viewResource = {
|
|
231
|
-
hostType: "mcp-app",
|
|
232
|
-
uri: `ui://views/ext-apps/${view.component}.html${versionParam}`,
|
|
233
|
-
mimeType: "text/html;profile=mcp-app",
|
|
234
|
-
buildContentMeta: ({ resourceDomains, connectDomains, domain, baseUriDomains }, overrides) => {
|
|
235
|
-
const defaults = {
|
|
236
|
-
ui: {
|
|
237
|
-
csp: {
|
|
238
|
-
resourceDomains,
|
|
239
|
-
connectDomains,
|
|
240
|
-
baseUriDomains,
|
|
241
|
-
},
|
|
242
|
-
domain,
|
|
511
|
+
const viewResource = {
|
|
512
|
+
hostType: "mcp-app",
|
|
513
|
+
uri: `ui://views/ext-apps/${view.component}.html${versionParam}`,
|
|
514
|
+
mimeType: "text/html;profile=mcp-app",
|
|
515
|
+
buildContentMeta: ({ resourceDomains, connectDomains, domain, baseUriDomains }, overrides) => {
|
|
516
|
+
const defaults = {
|
|
517
|
+
ui: {
|
|
518
|
+
csp: {
|
|
519
|
+
resourceDomains,
|
|
520
|
+
connectDomains,
|
|
521
|
+
baseUriDomains,
|
|
243
522
|
},
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
523
|
+
domain,
|
|
524
|
+
},
|
|
525
|
+
};
|
|
526
|
+
const fromView = {
|
|
527
|
+
ui: {
|
|
528
|
+
...(view.description && { description: view.description }),
|
|
529
|
+
...(view.prefersBorder !== undefined && {
|
|
530
|
+
prefersBorder: view.prefersBorder,
|
|
531
|
+
}),
|
|
532
|
+
...(view.domain && { domain: view.domain }),
|
|
533
|
+
csp: {
|
|
534
|
+
...(view.csp?.resourceDomains && {
|
|
535
|
+
resourceDomains: view.csp.resourceDomains,
|
|
536
|
+
}),
|
|
537
|
+
...(view.csp?.connectDomains && {
|
|
538
|
+
connectDomains: view.csp.connectDomains,
|
|
539
|
+
}),
|
|
540
|
+
...(view.csp?.frameDomains && {
|
|
541
|
+
frameDomains: view.csp.frameDomains,
|
|
542
|
+
}),
|
|
543
|
+
...(view.csp?.baseUriDomains && {
|
|
544
|
+
baseUriDomains: view.csp.baseUriDomains,
|
|
250
545
|
}),
|
|
251
|
-
...(view.domain && { domain: view.domain }),
|
|
252
|
-
csp: {
|
|
253
|
-
...(view.csp?.resourceDomains && {
|
|
254
|
-
resourceDomains: view.csp.resourceDomains,
|
|
255
|
-
}),
|
|
256
|
-
...(view.csp?.connectDomains && {
|
|
257
|
-
connectDomains: view.csp.connectDomains,
|
|
258
|
-
}),
|
|
259
|
-
...(view.csp?.frameDomains && {
|
|
260
|
-
frameDomains: view.csp.frameDomains,
|
|
261
|
-
}),
|
|
262
|
-
...(view.csp?.baseUriDomains && {
|
|
263
|
-
baseUriDomains: view.csp.baseUriDomains,
|
|
264
|
-
}),
|
|
265
|
-
...(view.csp?.redirectDomains && {
|
|
266
|
-
redirectDomains: view.csp.redirectDomains,
|
|
267
|
-
}),
|
|
268
|
-
},
|
|
269
546
|
},
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
547
|
+
},
|
|
548
|
+
};
|
|
549
|
+
const ui = mergeWithUnion(mergeWithUnion(defaults, fromView), {
|
|
550
|
+
ui: overrides,
|
|
551
|
+
});
|
|
552
|
+
const base = {
|
|
553
|
+
...ui,
|
|
554
|
+
...(view.description && {
|
|
555
|
+
"openai/widgetDescription": view.description,
|
|
556
|
+
}),
|
|
557
|
+
...(view.csp?.redirectDomains && {
|
|
558
|
+
"openai/widgetCSP": { redirect_domains: view.csp.redirectDomains },
|
|
559
|
+
}),
|
|
560
|
+
};
|
|
561
|
+
if (view._meta) {
|
|
562
|
+
return { ...base, ...view._meta };
|
|
563
|
+
}
|
|
564
|
+
return base;
|
|
565
|
+
},
|
|
566
|
+
};
|
|
567
|
+
this.registerViewResource({ name: toolName, viewResource, view });
|
|
568
|
+
// Advertise via the MCP Apps standard pointer only — ChatGPT renders from
|
|
569
|
+
// ui.resourceUri (verified), and not emitting openai/outputTemplate lets us
|
|
570
|
+
// retire the legacy apps-sdk resource later. The legacy apps-sdk URL is still
|
|
571
|
+
// served (see registerViewResource) so already-published apps keep resolving.
|
|
572
|
+
// @ts-expect-error - For backwards compatibility with Claude current implementation of the specs
|
|
573
|
+
toolMeta["ui/resourceUri"] = viewResource.uri;
|
|
574
|
+
toolMeta.ui = { ...toolMeta.ui, resourceUri: viewResource.uri };
|
|
289
575
|
}
|
|
290
576
|
registerViewResource({ name, viewResource, view, }) {
|
|
291
577
|
const { hostType, uri: viewUri, mimeType, buildContentMeta } = viewResource;
|
|
578
|
+
const buildMeta = (extra) => {
|
|
579
|
+
const { serverUrl, connectDomains, contentMetaOverrides } = this.resolveViewRequestContext(extra);
|
|
580
|
+
return buildContentMeta({
|
|
581
|
+
resourceDomains: [serverUrl],
|
|
582
|
+
connectDomains,
|
|
583
|
+
domain: serverUrl,
|
|
584
|
+
baseUriDomains: [serverUrl],
|
|
585
|
+
}, contentMetaOverrides);
|
|
586
|
+
};
|
|
587
|
+
this.viewMetaBuilders.set(viewUri, buildMeta);
|
|
588
|
+
this.viewUriByPath.set(stripQuery(viewUri), viewUri);
|
|
589
|
+
this.serveLegacyAppsSdkUrl(view.component, viewUri);
|
|
292
590
|
this.registerResource(name, viewUri, { description: view.description }, async (uri, extra) => {
|
|
293
591
|
const isProduction = process.env.NODE_ENV === "production";
|
|
294
|
-
const
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
};
|
|
300
|
-
let serverUrl;
|
|
301
|
-
const forwardedHost = header("x-forwarded-host");
|
|
302
|
-
const origin = header("origin");
|
|
303
|
-
const host = header("host");
|
|
304
|
-
if (forwardedHost) {
|
|
305
|
-
const proto = header("x-forwarded-proto") || "https";
|
|
306
|
-
serverUrl = `${proto}://${forwardedHost}`;
|
|
307
|
-
}
|
|
308
|
-
else if (origin) {
|
|
309
|
-
serverUrl = origin;
|
|
310
|
-
}
|
|
311
|
-
else if (host) {
|
|
312
|
-
const proto = ["127.0.0.1:", "localhost:"].some((p) => host.startsWith(p))
|
|
313
|
-
? "http"
|
|
314
|
-
: "https";
|
|
315
|
-
serverUrl = `${proto}://${host}`;
|
|
316
|
-
}
|
|
317
|
-
else {
|
|
318
|
-
const devPort = process.env.__PORT || "3000";
|
|
319
|
-
serverUrl = `http://localhost:${devPort}`;
|
|
320
|
-
}
|
|
592
|
+
const { serverUrl, assetsBasePath } = this.resolveViewRequestContext(extra);
|
|
593
|
+
// The view resolves all assets (template imports + runtime lazy chunks
|
|
594
|
+
// via `window.skybridge.serverUrl`) against this base, so it carries the
|
|
595
|
+
// proxy path prefix. CSP domains in `buildMeta` stay the bare origin.
|
|
596
|
+
const viewBase = `${serverUrl}${assetsBasePath}`;
|
|
321
597
|
const html = isProduction
|
|
322
598
|
? templateHelper.renderProduction({
|
|
323
599
|
hostType,
|
|
324
|
-
serverUrl,
|
|
600
|
+
serverUrl: viewBase,
|
|
325
601
|
viewFile: this.lookupViewFile(view.component),
|
|
326
602
|
styleFile: this.lookupDistFile("style.css") ?? "",
|
|
327
603
|
})
|
|
328
604
|
: templateHelper.renderDevelopment({
|
|
329
605
|
hostType,
|
|
330
|
-
serverUrl,
|
|
606
|
+
serverUrl: viewBase,
|
|
331
607
|
viewName: view.component,
|
|
332
608
|
});
|
|
333
|
-
const connectDomains = [serverUrl];
|
|
334
|
-
if (!isProduction) {
|
|
335
|
-
const wsUrl = new URL(serverUrl);
|
|
336
|
-
wsUrl.protocol = wsUrl.protocol === "https:" ? "wss:" : "ws:";
|
|
337
|
-
connectDomains.push(wsUrl.origin);
|
|
338
|
-
}
|
|
339
|
-
let contentMetaOverrides = {};
|
|
340
|
-
if (isClaude) {
|
|
341
|
-
const pathname = extra?.requestInfo?.url?.pathname ?? "";
|
|
342
|
-
const rawUrl = header("x-alpic-forwarded-url") ?? `${serverUrl}${pathname}`;
|
|
343
|
-
// Strip a lone trailing slash so the hash matches the connector URL
|
|
344
|
-
// as registered with Claude (which has no trailing slash on bare origins).
|
|
345
|
-
const url = rawUrl.endsWith("/") ? rawUrl.slice(0, -1) : rawUrl;
|
|
346
|
-
const hash = crypto
|
|
347
|
-
.createHash("sha256")
|
|
348
|
-
.update(url)
|
|
349
|
-
.digest("hex")
|
|
350
|
-
.slice(0, 32);
|
|
351
|
-
contentMetaOverrides = { domain: `${hash}.claudemcpcontent.com` };
|
|
352
|
-
}
|
|
353
|
-
const contentMeta = buildContentMeta({
|
|
354
|
-
resourceDomains: [serverUrl],
|
|
355
|
-
connectDomains,
|
|
356
|
-
domain: serverUrl,
|
|
357
|
-
baseUriDomains: [serverUrl],
|
|
358
|
-
}, contentMetaOverrides);
|
|
359
609
|
return {
|
|
360
610
|
contents: [
|
|
361
|
-
{ uri: uri.href, mimeType, text: html, _meta:
|
|
611
|
+
{ uri: uri.href, mimeType, text: html, _meta: buildMeta(extra) },
|
|
362
612
|
],
|
|
363
613
|
};
|
|
364
614
|
});
|
|
365
615
|
}
|
|
366
|
-
|
|
616
|
+
serveLegacyAppsSdkUrl(component, canonicalUri) {
|
|
617
|
+
this.viewUriByPath.set(`ui://views/apps-sdk/${component}.html`, canonicalUri);
|
|
618
|
+
this.viewUriByPath.set(`ui://widgets/apps-sdk/${component}.html`, canonicalUri);
|
|
619
|
+
this.viewUriByPath.set(`ui://widgets/ext-apps/${component}.html`, canonicalUri);
|
|
620
|
+
}
|
|
621
|
+
decorateToolHandler(cb, { attachViewUUID, securitySchemes, }) {
|
|
367
622
|
return async (args, extra) => {
|
|
623
|
+
if (this.oauthEnabled) {
|
|
624
|
+
const failure = evaluateSecuritySchemes(securitySchemes, extra.authInfo);
|
|
625
|
+
if (failure) {
|
|
626
|
+
const headers = extra?.requestInfo?.headers ?? {};
|
|
627
|
+
const header = (key) => {
|
|
628
|
+
const value = headers[key];
|
|
629
|
+
return Array.isArray(value) ? value[0] : value;
|
|
630
|
+
};
|
|
631
|
+
return inBandChallengeResult(failure, this.resolveResourceMetadataUrl?.(header));
|
|
632
|
+
}
|
|
633
|
+
}
|
|
368
634
|
const result = await cb(args, extra);
|
|
369
635
|
return {
|
|
370
636
|
...result,
|
|
@@ -411,24 +677,53 @@ export class McpServer extends McpServerBaseOmitted {
|
|
|
411
677
|
const manifest = this.readManifest();
|
|
412
678
|
return manifest[key]?.file;
|
|
413
679
|
}
|
|
680
|
+
/**
|
|
681
|
+
* Inject the Vite manifest as a value rather than letting `readManifest()`
|
|
682
|
+
* load it from disk. Required for runtimes without a usable filesystem
|
|
683
|
+
* (Cloudflare Workers, etc.) — the user's `skybridge build` emits the
|
|
684
|
+
* manifest as a JS module which the entry imports and passes here.
|
|
685
|
+
*/
|
|
686
|
+
setViteManifest(manifest) {
|
|
687
|
+
this.viteManifest = manifest;
|
|
688
|
+
return this;
|
|
689
|
+
}
|
|
414
690
|
readManifest() {
|
|
691
|
+
if (this.viteManifest) {
|
|
692
|
+
return this.viteManifest;
|
|
693
|
+
}
|
|
415
694
|
return JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
416
695
|
}
|
|
417
696
|
registerTool(...args) {
|
|
418
697
|
const baseFn = McpServerBase.prototype.registerTool;
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
698
|
+
const { config, cb } = normalizeRegisterToolArgs(args);
|
|
699
|
+
const { name, view, auth, securitySchemes: rawSecuritySchemes, _meta: userToolMeta, ...toolFields } = config;
|
|
700
|
+
const authNeedsProvider = auth !== undefined &&
|
|
701
|
+
(!auth.allowsAnonymous || Boolean(auth.scopes?.length));
|
|
702
|
+
if (rawSecuritySchemes === undefined &&
|
|
703
|
+
authNeedsProvider &&
|
|
704
|
+
!this.oauthEnabled) {
|
|
705
|
+
throw new Error(`Tool "${name}" sets \`auth: ${JSON.stringify(auth)}\` but the server has no \`oauth\` provider configured.`);
|
|
422
706
|
}
|
|
423
|
-
const
|
|
424
|
-
|
|
425
|
-
const { name, view, _meta: userToolMeta, ...toolFields } = config;
|
|
707
|
+
const securitySchemes = rawSecuritySchemes ??
|
|
708
|
+
(auth && this.oauthEnabled ? authToSecuritySchemes(auth) : undefined);
|
|
426
709
|
const toolMeta = { ...userToolMeta };
|
|
710
|
+
this.securitySchemesByTool.set(name, securitySchemes);
|
|
711
|
+
if (securitySchemes) {
|
|
712
|
+
// SEP-1488 puts `securitySchemes` at the top level of the tool
|
|
713
|
+
// descriptor, but the SDK's `registerTool` drops unknown top-level
|
|
714
|
+
// fields, so the canonical spot isn't reachable without intercepting
|
|
715
|
+
// `tools/list`. Use the `_meta` back-compat mirror documented in the
|
|
716
|
+
// Apps SDK reference until SEP-1488 lands in the spec.
|
|
717
|
+
toolMeta.securitySchemes = securitySchemes;
|
|
718
|
+
}
|
|
427
719
|
if (view) {
|
|
428
720
|
this.enforceOneToolPerView(view.component, name);
|
|
429
721
|
this.registerViewResources(name, view, toolMeta);
|
|
430
722
|
}
|
|
431
|
-
const wrappedCb = this.
|
|
723
|
+
const wrappedCb = this.decorateToolHandler(cb, {
|
|
724
|
+
attachViewUUID: Boolean(view),
|
|
725
|
+
securitySchemes,
|
|
726
|
+
});
|
|
432
727
|
baseFn.call(this, name, { ...toolFields, _meta: toolMeta }, wrappedCb);
|
|
433
728
|
return this;
|
|
434
729
|
}
|