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