skybridge 0.0.0-dev.f49389e → 0.0.0-dev.f4d220f
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/LICENSE +21 -674
- package/README.md +97 -142
- package/bin/run.js +5 -0
- package/dist/cli/detect-port.d.ts +18 -0
- package/dist/cli/detect-port.js +61 -0
- package/dist/cli/detect-port.js.map +1 -0
- package/dist/cli/header.d.ts +4 -0
- package/dist/cli/header.js +6 -0
- package/dist/cli/header.js.map +1 -0
- package/dist/cli/run-command.d.ts +2 -0
- package/dist/cli/run-command.js +43 -0
- package/dist/cli/run-command.js.map +1 -0
- package/dist/cli/telemetry.d.ts +7 -0
- package/dist/cli/telemetry.js +123 -0
- package/dist/cli/telemetry.js.map +1 -0
- package/dist/cli/tunnel-control-server.d.ts +9 -0
- package/dist/cli/tunnel-control-server.js +31 -0
- package/dist/cli/tunnel-control-server.js.map +1 -0
- package/dist/cli/tunnel-control-server.test.js +39 -0
- package/dist/cli/tunnel-control-server.test.js.map +1 -0
- package/dist/cli/tunnel-handler.d.ts +3 -0
- package/dist/cli/tunnel-handler.js +48 -0
- package/dist/cli/tunnel-handler.js.map +1 -0
- package/dist/cli/tunnel-handler.test.js +105 -0
- package/dist/cli/tunnel-handler.test.js.map +1 -0
- package/dist/cli/tunnel.d.ts +57 -0
- package/dist/cli/tunnel.js +154 -0
- package/dist/cli/tunnel.js.map +1 -0
- package/dist/cli/tunnel.test.js +190 -0
- package/dist/cli/tunnel.test.js.map +1 -0
- package/dist/cli/types.d.ts +5 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/use-execute-steps.d.ts +11 -0
- package/dist/cli/use-execute-steps.js +36 -0
- package/dist/cli/use-execute-steps.js.map +1 -0
- package/dist/cli/use-messages.d.ts +3 -0
- package/dist/cli/use-messages.js +11 -0
- package/dist/cli/use-messages.js.map +1 -0
- package/dist/cli/use-nodemon.d.ts +2 -0
- package/dist/cli/use-nodemon.js +64 -0
- package/dist/cli/use-nodemon.js.map +1 -0
- package/dist/cli/use-tunnel.d.ts +14 -0
- package/dist/cli/use-tunnel.js +131 -0
- package/dist/cli/use-tunnel.js.map +1 -0
- package/dist/cli/use-typescript-check.d.ts +9 -0
- package/dist/cli/use-typescript-check.js +94 -0
- package/dist/cli/use-typescript-check.js.map +1 -0
- package/dist/commands/build.d.ts +9 -0
- package/dist/commands/build.js +67 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/dev.d.ts +11 -0
- package/dist/commands/dev.js +73 -0
- package/dist/commands/dev.js.map +1 -0
- package/dist/commands/start.d.ts +9 -0
- package/dist/commands/start.js +49 -0
- package/dist/commands/start.js.map +1 -0
- package/dist/commands/telemetry/disable.d.ts +5 -0
- package/dist/commands/telemetry/disable.js +14 -0
- package/dist/commands/telemetry/disable.js.map +1 -0
- package/dist/commands/telemetry/enable.d.ts +5 -0
- package/dist/commands/telemetry/enable.js +14 -0
- package/dist/commands/telemetry/enable.js.map +1 -0
- package/dist/commands/telemetry/status.d.ts +5 -0
- package/dist/commands/telemetry/status.js +14 -0
- package/dist/commands/telemetry/status.js.map +1 -0
- package/dist/server/asset-base-url-transform-plugin.d.ts +10 -0
- package/dist/server/asset-base-url-transform-plugin.js +33 -0
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -0
- package/dist/server/asset-base-url-transform-plugin.test.js +84 -0
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -0
- package/dist/server/content-helpers.d.ts +27 -0
- package/dist/server/content-helpers.js +46 -0
- package/dist/server/content-helpers.js.map +1 -0
- package/dist/server/content-helpers.test.js +70 -0
- package/dist/server/content-helpers.test.js.map +1 -0
- package/dist/server/express.d.ts +15 -0
- package/dist/server/express.js +95 -0
- package/dist/server/express.js.map +1 -0
- package/dist/server/express.test.js +348 -0
- package/dist/server/express.test.js.map +1 -0
- package/dist/server/index.d.ts +6 -0
- package/dist/server/index.js +4 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/inferUtilityTypes.d.ts +64 -0
- package/dist/server/inferUtilityTypes.js +2 -0
- package/dist/server/inferUtilityTypes.js.map +1 -0
- package/dist/server/metric.d.ts +14 -0
- package/dist/server/metric.js +62 -0
- package/dist/server/metric.js.map +1 -0
- package/dist/server/middleware.d.ts +124 -0
- package/dist/server/middleware.js +93 -0
- package/dist/server/middleware.js.map +1 -0
- package/dist/server/middleware.test-d.js +75 -0
- package/dist/server/middleware.test-d.js.map +1 -0
- package/dist/server/middleware.test.js +493 -0
- package/dist/server/middleware.test.js.map +1 -0
- package/dist/server/server.d.ts +173 -0
- package/dist/server/server.js +436 -0
- package/dist/server/server.js.map +1 -0
- package/dist/{src/server → server}/templateHelper.d.ts +5 -2
- package/dist/{src/server → server}/templateHelper.js +5 -4
- package/dist/server/templateHelper.js.map +1 -0
- package/dist/server/templates/development.hbs +12 -0
- package/dist/server/templates/production.hbs +6 -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.js +229 -0
- package/dist/server/tunnel-proxy-router.test.js.map +1 -0
- package/dist/server/viewsDevServer.d.ts +14 -0
- package/dist/server/viewsDevServer.js +45 -0
- package/dist/server/viewsDevServer.js.map +1 -0
- package/dist/test/utils.d.ts +127 -0
- package/dist/test/utils.js +247 -0
- package/dist/test/utils.js.map +1 -0
- package/dist/test/view.test.js +523 -0
- package/dist/test/view.test.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +24 -0
- package/dist/web/bridges/apps-sdk/adaptor.js +93 -0
- package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -0
- package/dist/web/bridges/apps-sdk/bridge.d.ts +10 -0
- package/dist/web/bridges/apps-sdk/bridge.js +46 -0
- package/dist/web/bridges/apps-sdk/bridge.js.map +1 -0
- package/dist/web/bridges/apps-sdk/index.d.ts +5 -0
- package/dist/web/bridges/apps-sdk/index.js +5 -0
- package/dist/web/bridges/apps-sdk/index.js.map +1 -0
- package/dist/web/bridges/apps-sdk/types.d.ts +126 -0
- package/dist/web/bridges/apps-sdk/types.js.map +1 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +2 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +7 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -0
- package/dist/web/bridges/get-adaptor.d.ts +2 -0
- package/dist/web/bridges/get-adaptor.js +8 -0
- package/dist/web/bridges/get-adaptor.js.map +1 -0
- package/dist/web/bridges/index.d.ts +5 -0
- package/dist/web/bridges/index.js +6 -0
- package/dist/web/bridges/index.js.map +1 -0
- package/dist/web/bridges/mcp-app/adaptor.d.ts +48 -0
- package/dist/web/bridges/mcp-app/adaptor.js +268 -0
- package/dist/web/bridges/mcp-app/adaptor.js.map +1 -0
- package/dist/web/bridges/mcp-app/bridge.d.ts +26 -0
- package/dist/web/bridges/mcp-app/bridge.js +102 -0
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -0
- package/dist/web/bridges/mcp-app/index.d.ts +4 -0
- package/dist/web/bridges/mcp-app/index.js +4 -0
- package/dist/web/bridges/mcp-app/index.js.map +1 -0
- package/dist/web/bridges/mcp-app/types.d.ts +8 -0
- package/dist/web/bridges/mcp-app/types.js +2 -0
- package/dist/web/bridges/mcp-app/types.js.map +1 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +7 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +7 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +26 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -0
- package/dist/web/bridges/types.d.ts +109 -0
- package/dist/web/bridges/types.js +2 -0
- package/dist/web/bridges/types.js.map +1 -0
- package/dist/web/bridges/use-host-context.d.ts +2 -0
- package/dist/web/bridges/use-host-context.js +8 -0
- package/dist/web/bridges/use-host-context.js.map +1 -0
- package/dist/web/components/modal-provider.d.ts +4 -0
- package/dist/web/components/modal-provider.js +45 -0
- package/dist/web/components/modal-provider.js.map +1 -0
- package/dist/web/create-store.d.ts +3 -0
- package/dist/web/create-store.js +38 -0
- package/dist/web/create-store.js.map +1 -0
- package/dist/web/create-store.test.d.ts +1 -0
- package/dist/web/create-store.test.js +129 -0
- package/dist/web/create-store.test.js.map +1 -0
- package/dist/web/data-llm.d.ts +14 -0
- package/dist/web/data-llm.js +72 -0
- package/dist/web/data-llm.js.map +1 -0
- package/dist/web/data-llm.test.d.ts +1 -0
- package/dist/web/data-llm.test.js +142 -0
- package/dist/web/data-llm.test.js.map +1 -0
- package/dist/web/generate-helpers.d.ts +118 -0
- package/dist/web/generate-helpers.js +113 -0
- package/dist/web/generate-helpers.js.map +1 -0
- package/dist/web/generate-helpers.test-d.d.ts +1 -0
- package/dist/web/generate-helpers.test-d.js +209 -0
- package/dist/web/generate-helpers.test-d.js.map +1 -0
- package/dist/web/generate-helpers.test.d.ts +1 -0
- package/dist/web/generate-helpers.test.js +17 -0
- package/dist/web/generate-helpers.test.js.map +1 -0
- package/dist/web/helpers/state.d.ts +7 -0
- package/dist/web/helpers/state.js +45 -0
- package/dist/web/helpers/state.js.map +1 -0
- package/dist/web/helpers/state.test.d.ts +1 -0
- package/dist/web/helpers/state.test.js +53 -0
- package/dist/web/helpers/state.test.js.map +1 -0
- package/dist/web/hooks/index.d.ts +11 -0
- package/dist/web/hooks/index.js +12 -0
- package/dist/web/hooks/index.js.map +1 -0
- package/dist/web/hooks/test/utils.d.ts +16 -0
- package/dist/web/hooks/test/utils.js +64 -0
- package/dist/web/hooks/test/utils.js.map +1 -0
- package/dist/web/hooks/use-call-tool.d.ts +101 -0
- package/dist/web/hooks/use-call-tool.js +68 -0
- package/dist/web/hooks/use-call-tool.js.map +1 -0
- package/dist/web/hooks/use-call-tool.test-d.d.ts +1 -0
- package/dist/web/hooks/use-call-tool.test-d.js +104 -0
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
- package/dist/web/hooks/use-call-tool.test.d.ts +1 -0
- package/dist/{src/web → web}/hooks/use-call-tool.test.js +41 -15
- package/dist/web/hooks/use-call-tool.test.js.map +1 -0
- package/dist/web/hooks/use-display-mode.d.ts +4 -0
- package/dist/web/hooks/use-display-mode.js +9 -0
- package/dist/web/hooks/use-display-mode.js.map +1 -0
- package/dist/web/hooks/use-display-mode.test-d.d.ts +1 -0
- package/dist/web/hooks/use-display-mode.test-d.js +8 -0
- package/dist/web/hooks/use-display-mode.test-d.js.map +1 -0
- package/dist/web/hooks/use-display-mode.test.d.ts +1 -0
- package/dist/{src/web → web}/hooks/use-display-mode.test.js +3 -2
- package/dist/web/hooks/use-display-mode.test.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +7 -0
- package/dist/web/hooks/use-files.js +10 -0
- package/dist/web/hooks/use-files.js.map +1 -0
- package/dist/web/hooks/use-files.test.d.ts +1 -0
- package/dist/web/hooks/use-files.test.js +54 -0
- package/dist/web/hooks/use-files.test.js.map +1 -0
- package/dist/web/hooks/use-layout.d.ts +22 -0
- package/dist/web/hooks/use-layout.js +23 -0
- package/dist/web/hooks/use-layout.js.map +1 -0
- package/dist/web/hooks/use-layout.test.d.ts +1 -0
- package/dist/web/hooks/use-layout.test.js +96 -0
- package/dist/web/hooks/use-layout.test.js.map +1 -0
- package/dist/web/hooks/use-open-external.d.ts +3 -0
- package/dist/web/hooks/use-open-external.js +8 -0
- package/dist/web/hooks/use-open-external.js.map +1 -0
- package/dist/web/hooks/use-open-external.test.d.ts +1 -0
- package/dist/web/hooks/use-open-external.test.js +65 -0
- package/dist/web/hooks/use-open-external.test.js.map +1 -0
- package/dist/web/hooks/use-request-modal.d.ts +9 -0
- package/dist/web/hooks/use-request-modal.js +16 -0
- package/dist/web/hooks/use-request-modal.js.map +1 -0
- package/dist/web/hooks/use-request-modal.test.d.ts +1 -0
- package/dist/web/hooks/use-request-modal.test.js +61 -0
- package/dist/web/hooks/use-request-modal.test.js.map +1 -0
- package/dist/web/hooks/use-send-follow-up-message.js +8 -0
- package/dist/web/hooks/use-send-follow-up-message.js.map +1 -0
- package/dist/web/hooks/use-set-open-in-app-url.d.ts +1 -0
- package/dist/web/hooks/use-set-open-in-app-url.js +8 -0
- package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -0
- package/dist/web/hooks/use-set-open-in-app-url.test.d.ts +1 -0
- package/dist/web/hooks/use-set-open-in-app-url.test.js +43 -0
- package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -0
- package/dist/web/hooks/use-tool-info.d.ts +36 -0
- package/dist/web/hooks/use-tool-info.js +26 -0
- package/dist/web/hooks/use-tool-info.js.map +1 -0
- package/dist/web/hooks/use-tool-info.test-d.d.ts +1 -0
- package/dist/web/hooks/use-tool-info.test-d.js +109 -0
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -0
- package/dist/web/hooks/use-tool-info.test.d.ts +1 -0
- package/dist/web/hooks/use-tool-info.test.js +130 -0
- package/dist/web/hooks/use-tool-info.test.js.map +1 -0
- package/dist/web/hooks/use-user.d.ts +18 -0
- package/dist/web/hooks/use-user.js +35 -0
- package/dist/web/hooks/use-user.js.map +1 -0
- package/dist/web/hooks/use-user.test.d.ts +1 -0
- package/dist/web/hooks/use-user.test.js +122 -0
- package/dist/web/hooks/use-user.test.js.map +1 -0
- package/dist/web/hooks/use-view-state.d.ts +4 -0
- package/dist/web/hooks/use-view-state.js +32 -0
- package/dist/web/hooks/use-view-state.js.map +1 -0
- package/dist/web/hooks/use-view-state.test.d.ts +1 -0
- package/dist/web/hooks/use-view-state.test.js +177 -0
- package/dist/web/hooks/use-view-state.test.js.map +1 -0
- package/dist/web/index.d.ts +7 -0
- package/dist/web/index.js +8 -0
- package/dist/web/index.js.map +1 -0
- package/dist/web/mount-view.d.ts +1 -0
- package/dist/web/mount-view.js +27 -0
- package/dist/web/mount-view.js.map +1 -0
- package/dist/web/plugin/data-llm.test.d.ts +1 -0
- package/dist/web/plugin/data-llm.test.js +81 -0
- package/dist/web/plugin/data-llm.test.js.map +1 -0
- package/dist/web/plugin/plugin.d.ts +5 -0
- package/dist/web/plugin/plugin.js +163 -0
- package/dist/web/plugin/plugin.js.map +1 -0
- package/dist/web/plugin/scan-views.d.ts +16 -0
- package/dist/web/plugin/scan-views.js +88 -0
- package/dist/web/plugin/scan-views.js.map +1 -0
- package/dist/web/plugin/scan-views.test.d.ts +1 -0
- package/dist/web/plugin/scan-views.test.js +99 -0
- package/dist/web/plugin/scan-views.test.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.d.ts +12 -0
- package/dist/web/plugin/transform-data-llm.js +96 -0
- package/dist/web/plugin/transform-data-llm.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.test.d.ts +1 -0
- package/dist/web/plugin/transform-data-llm.test.js +81 -0
- package/dist/web/plugin/transform-data-llm.test.js.map +1 -0
- package/dist/web/plugin/validate-view.d.ts +1 -0
- package/dist/web/plugin/validate-view.js +9 -0
- package/dist/web/plugin/validate-view.js.map +1 -0
- package/dist/web/plugin/validate-view.test.d.ts +1 -0
- package/dist/web/plugin/validate-view.test.js +24 -0
- package/dist/web/plugin/validate-view.test.js.map +1 -0
- package/dist/web/proxy.d.ts +1 -0
- package/dist/web/proxy.js +52 -0
- package/dist/web/proxy.js.map +1 -0
- package/dist/web/types.d.ts +16 -0
- package/dist/web/types.js +2 -0
- package/dist/web/types.js.map +1 -0
- package/package.json +78 -35
- package/tsconfig.base.json +33 -0
- package/dist/src/server/index.d.ts +0 -2
- package/dist/src/server/index.js +0 -3
- package/dist/src/server/index.js.map +0 -1
- package/dist/src/server/server.d.ts +0 -13
- package/dist/src/server/server.js +0 -54
- package/dist/src/server/server.js.map +0 -1
- package/dist/src/server/templateHelper.js.map +0 -1
- package/dist/src/server/templates/development.hbs +0 -12
- package/dist/src/server/templates/production.hbs +0 -6
- package/dist/src/server/widgetsDevServer.d.ts +0 -12
- package/dist/src/server/widgetsDevServer.js +0 -39
- package/dist/src/server/widgetsDevServer.js.map +0 -1
- package/dist/src/test/setup.js +0 -9
- package/dist/src/test/setup.js.map +0 -1
- package/dist/src/test/utils.d.ts +0 -28
- package/dist/src/test/utils.js +0 -43
- package/dist/src/test/utils.js.map +0 -1
- package/dist/src/test/widget.test.js +0 -90
- package/dist/src/test/widget.test.js.map +0 -1
- package/dist/src/web/hooks/index.d.ts +0 -13
- package/dist/src/web/hooks/index.js +0 -14
- package/dist/src/web/hooks/index.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.d.ts +0 -62
- package/dist/src/web/hooks/use-call-tool.js +0 -66
- package/dist/src/web/hooks/use-call-tool.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.test.js.map +0 -1
- package/dist/src/web/hooks/use-display-mode.d.ts +0 -4
- package/dist/src/web/hooks/use-display-mode.js +0 -7
- package/dist/src/web/hooks/use-display-mode.js.map +0 -1
- package/dist/src/web/hooks/use-display-mode.test.js.map +0 -1
- package/dist/src/web/hooks/use-locale.d.ts +0 -1
- package/dist/src/web/hooks/use-locale.js +0 -5
- package/dist/src/web/hooks/use-locale.js.map +0 -1
- package/dist/src/web/hooks/use-locale.test.js +0 -21
- package/dist/src/web/hooks/use-locale.test.js.map +0 -1
- package/dist/src/web/hooks/use-open-external.d.ts +0 -1
- package/dist/src/web/hooks/use-open-external.js +0 -6
- package/dist/src/web/hooks/use-open-external.js.map +0 -1
- package/dist/src/web/hooks/use-open-external.test.js +0 -24
- package/dist/src/web/hooks/use-open-external.test.js.map +0 -1
- package/dist/src/web/hooks/use-openai-global.d.ts +0 -2
- package/dist/src/web/hooks/use-openai-global.js +0 -21
- package/dist/src/web/hooks/use-openai-global.js.map +0 -1
- package/dist/src/web/hooks/use-request-modal.d.ts +0 -5
- package/dist/src/web/hooks/use-request-modal.js +0 -9
- package/dist/src/web/hooks/use-request-modal.js.map +0 -1
- package/dist/src/web/hooks/use-request-modal.test.js +0 -24
- package/dist/src/web/hooks/use-request-modal.test.js.map +0 -1
- package/dist/src/web/hooks/use-send-follow-up-message.js +0 -11
- package/dist/src/web/hooks/use-send-follow-up-message.js.map +0 -1
- package/dist/src/web/hooks/use-theme.d.ts +0 -1
- package/dist/src/web/hooks/use-theme.js +0 -5
- package/dist/src/web/hooks/use-theme.js.map +0 -1
- package/dist/src/web/hooks/use-theme.test.js +0 -26
- package/dist/src/web/hooks/use-theme.test.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.d.ts +0 -5
- package/dist/src/web/hooks/use-tool-info.js +0 -9
- package/dist/src/web/hooks/use-tool-info.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.test.js +0 -38
- package/dist/src/web/hooks/use-tool-info.test.js.map +0 -1
- package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
- package/dist/src/web/hooks/use-tool-output.js +0 -9
- package/dist/src/web/hooks/use-tool-output.js.map +0 -1
- package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
- package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
- package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
- package/dist/src/web/hooks/use-user-agent.d.ts +0 -1
- package/dist/src/web/hooks/use-user-agent.js +0 -5
- package/dist/src/web/hooks/use-user-agent.js.map +0 -1
- package/dist/src/web/hooks/use-user-agent.test.js +0 -31
- package/dist/src/web/hooks/use-user-agent.test.js.map +0 -1
- package/dist/src/web/hooks/use-widget-state.d.ts +0 -4
- package/dist/src/web/hooks/use-widget-state.js +0 -30
- package/dist/src/web/hooks/use-widget-state.js.map +0 -1
- package/dist/src/web/hooks/use-widget-state.test.js +0 -61
- package/dist/src/web/hooks/use-widget-state.test.js.map +0 -1
- package/dist/src/web/index.d.ts +0 -4
- package/dist/src/web/index.js +0 -5
- package/dist/src/web/index.js.map +0 -1
- package/dist/src/web/mount-widget.d.ts +0 -1
- package/dist/src/web/mount-widget.js +0 -14
- package/dist/src/web/mount-widget.js.map +0 -1
- package/dist/src/web/plugin.d.ts +0 -2
- package/dist/src/web/plugin.js +0 -28
- package/dist/src/web/plugin.js.map +0 -1
- package/dist/src/web/types.d.ts +0 -114
- package/dist/src/web/types.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -9
- package/dist/vitest.config.js.map +0 -1
- /package/dist/{src/test/setup.d.ts → cli/tunnel-control-server.test.d.ts} +0 -0
- /package/dist/{src/test/widget.test.d.ts → cli/tunnel-handler.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-call-tool.test.d.ts → cli/tunnel.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-display-mode.test.d.ts → server/asset-base-url-transform-plugin.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-locale.test.d.ts → server/content-helpers.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-open-external.test.d.ts → server/express.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-request-modal.test.d.ts → server/middleware.test-d.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-theme.test.d.ts → server/middleware.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-tool-info.test.d.ts → server/tunnel-proxy-router.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-user-agent.test.d.ts → test/view.test.d.ts} +0 -0
- /package/dist/{src/web → web/bridges/apps-sdk}/types.js +0 -0
- /package/dist/{src/web/hooks/use-widget-state.test.d.ts → web/bridges/mcp-app/use-mcp-app-context.test.d.ts} +0 -0
- /package/dist/{src/web → web}/hooks/use-send-follow-up-message.d.ts +0 -0
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
import { type ServerOptions } from "@modelcontextprotocol/sdk/server/index.js";
|
|
2
|
+
import { McpServer as McpServerBase } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
3
|
+
import type { AnySchema, SchemaOutput, ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
4
|
+
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
5
|
+
import type { ContentBlock, Implementation, ServerNotification, ServerRequest, ServerResult, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
6
|
+
import type { ErrorRequestHandler, RequestHandler } from "express";
|
|
7
|
+
import type { McpExtra, McpExtraFor, McpMethodString, McpMiddlewareFilter, McpMiddlewareFn, McpResultFor, McpTypedMiddlewareFn, McpWildcard } from "./middleware.js";
|
|
8
|
+
export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unknown> = {
|
|
9
|
+
input: TInput;
|
|
10
|
+
output: TOutput;
|
|
11
|
+
responseMetadata: TResponseMetadata;
|
|
12
|
+
};
|
|
13
|
+
export type ViewHostType = "apps-sdk" | "mcp-app";
|
|
14
|
+
export interface ViewCsp {
|
|
15
|
+
/** Origins for static assets (images, fonts, scripts, styles). */
|
|
16
|
+
resourceDomains?: string[];
|
|
17
|
+
/** Origins the view may contact via fetch/XHR. */
|
|
18
|
+
connectDomains?: string[];
|
|
19
|
+
/** Origins allowed for iframe embeds (opts into stricter app review). */
|
|
20
|
+
frameDomains?: string[];
|
|
21
|
+
/** Origins that can receive openExternal redirects without the safe-link modal. */
|
|
22
|
+
redirectDomains?: string[];
|
|
23
|
+
/** Origins allowed in `<base href>` tags (mcp-apps only). */
|
|
24
|
+
baseUriDomains?: string[];
|
|
25
|
+
}
|
|
26
|
+
export interface ViewNameRegistry {
|
|
27
|
+
}
|
|
28
|
+
export type ViewName = keyof ViewNameRegistry & string;
|
|
29
|
+
export interface ViewConfig {
|
|
30
|
+
component: ViewName;
|
|
31
|
+
description?: string;
|
|
32
|
+
hosts?: ViewHostType[];
|
|
33
|
+
prefersBorder?: boolean;
|
|
34
|
+
domain?: string;
|
|
35
|
+
csp?: ViewCsp;
|
|
36
|
+
_meta?: Record<string, unknown>;
|
|
37
|
+
}
|
|
38
|
+
export interface KnownToolMeta {
|
|
39
|
+
"openai/widgetAccessible"?: boolean;
|
|
40
|
+
"openai/toolInvocation/invoking"?: string;
|
|
41
|
+
"openai/toolInvocation/invoked"?: string;
|
|
42
|
+
}
|
|
43
|
+
export type ToolMeta = KnownToolMeta & Record<string, unknown>;
|
|
44
|
+
export type HandlerContent = string | ContentBlock | ContentBlock[];
|
|
45
|
+
/**
|
|
46
|
+
* Type-level marker interface for cross-package type inference.
|
|
47
|
+
*
|
|
48
|
+
* Consumers infer tool types via the structural `$types` property rather than
|
|
49
|
+
* the `McpServer` class generic, because class-generic inference breaks when
|
|
50
|
+
* `McpServer` comes from different package installations (e.g. a consumer
|
|
51
|
+
* with its own `skybridge` dep vs. the in-tree workspace version).
|
|
52
|
+
*
|
|
53
|
+
* Inspired by tRPC's `_def` pattern and Hono's type markers.
|
|
54
|
+
*/
|
|
55
|
+
export interface McpServerTypes<TTools extends Record<string, ToolDef>> {
|
|
56
|
+
readonly tools: TTools;
|
|
57
|
+
}
|
|
58
|
+
type Simplify<T> = {
|
|
59
|
+
[K in keyof T]: T[K];
|
|
60
|
+
};
|
|
61
|
+
type ShapeOutput<Shape extends ZodRawShapeCompat> = Simplify<{
|
|
62
|
+
[K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? never : K]: SchemaOutput<Shape[K]>;
|
|
63
|
+
} & {
|
|
64
|
+
[K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? K : never]?: SchemaOutput<Shape[K]>;
|
|
65
|
+
}>;
|
|
66
|
+
type ExtractStructuredContent<T> = T extends {
|
|
67
|
+
structuredContent: infer SC;
|
|
68
|
+
} ? Simplify<SC> : never;
|
|
69
|
+
type ExtractMeta<T> = [Extract<T, {
|
|
70
|
+
_meta: unknown;
|
|
71
|
+
}>] extends [never] ? unknown : Extract<T, {
|
|
72
|
+
_meta: unknown;
|
|
73
|
+
}> extends {
|
|
74
|
+
_meta: infer M;
|
|
75
|
+
} ? Simplify<M> : unknown;
|
|
76
|
+
type AddTool<TTools, TName extends string, TInput extends ZodRawShapeCompat, TOutput, TResponseMetadata = unknown> = McpServer<TTools & {
|
|
77
|
+
[K in TName]: ToolDef<ShapeOutput<TInput>, TOutput, TResponseMetadata>;
|
|
78
|
+
}>;
|
|
79
|
+
interface ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> {
|
|
80
|
+
name: string;
|
|
81
|
+
title?: string;
|
|
82
|
+
description?: string;
|
|
83
|
+
inputSchema?: TInput;
|
|
84
|
+
outputSchema?: ZodRawShapeCompat | AnySchema;
|
|
85
|
+
annotations?: ToolAnnotations;
|
|
86
|
+
view?: ViewConfig;
|
|
87
|
+
_meta?: ToolMeta;
|
|
88
|
+
}
|
|
89
|
+
type ToolHandler<TInput extends ZodRawShapeCompat, TReturn extends {
|
|
90
|
+
content?: HandlerContent;
|
|
91
|
+
} = {
|
|
92
|
+
content?: HandlerContent;
|
|
93
|
+
}> = (args: ShapeOutput<TInput>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => TReturn | Promise<TReturn>;
|
|
94
|
+
export declare function normalizeContent(content: HandlerContent | undefined): ContentBlock[];
|
|
95
|
+
interface McpServerBaseOmitted extends Omit<McpServerBase, "registerTool" | "connect"> {
|
|
96
|
+
}
|
|
97
|
+
declare const McpServerBaseOmitted: new (...args: ConstructorParameters<typeof McpServerBase>) => McpServerBaseOmitted;
|
|
98
|
+
export declare class McpServer<TTools extends Record<string, ToolDef> = Record<never, ToolDef>> extends McpServerBaseOmitted {
|
|
99
|
+
readonly $types: McpServerTypes<TTools>;
|
|
100
|
+
private express?;
|
|
101
|
+
private customMiddleware;
|
|
102
|
+
private customErrorMiddleware;
|
|
103
|
+
private mcpMiddlewareEntries;
|
|
104
|
+
private mcpMiddlewareApplied;
|
|
105
|
+
private claimedViews;
|
|
106
|
+
private readonly serverInfo;
|
|
107
|
+
private readonly serverOptions?;
|
|
108
|
+
constructor(serverInfo: Implementation, options?: ServerOptions);
|
|
109
|
+
use(...handlers: RequestHandler[]): this;
|
|
110
|
+
use(path: string, ...handlers: RequestHandler[]): this;
|
|
111
|
+
useOnError(...handlers: ErrorRequestHandler[]): this;
|
|
112
|
+
useOnError(path: string, ...handlers: ErrorRequestHandler[]): this;
|
|
113
|
+
/** Register MCP protocol-level middleware (catch-all). */
|
|
114
|
+
mcpMiddleware(handler: McpMiddlewareFn): this;
|
|
115
|
+
/** Register MCP protocol-level middleware for all requests (`extra` is `McpExtra`). */
|
|
116
|
+
mcpMiddleware(filter: "request", handler: (request: {
|
|
117
|
+
method: string;
|
|
118
|
+
params: Record<string, unknown>;
|
|
119
|
+
}, extra: McpExtra, next: () => Promise<ServerResult>) => Promise<unknown> | unknown): this;
|
|
120
|
+
/** Register MCP protocol-level middleware for all notifications (`extra` is `undefined`). */
|
|
121
|
+
mcpMiddleware(filter: "notification", handler: (request: {
|
|
122
|
+
method: string;
|
|
123
|
+
params: Record<string, unknown>;
|
|
124
|
+
}, extra: undefined, next: () => Promise<undefined>) => Promise<unknown> | unknown): this;
|
|
125
|
+
/**
|
|
126
|
+
* Register MCP protocol-level middleware for an exact method.
|
|
127
|
+
* Narrows `params`, `extra`, and `next()` result based on the method string.
|
|
128
|
+
*/
|
|
129
|
+
mcpMiddleware<M extends McpMethodString>(filter: M, handler: McpTypedMiddlewareFn<M>): this;
|
|
130
|
+
/**
|
|
131
|
+
* Register MCP protocol-level middleware for a wildcard pattern (e.g. `"tools/*"`).
|
|
132
|
+
* `next()` returns the union of result types for matching methods.
|
|
133
|
+
*/
|
|
134
|
+
mcpMiddleware<W extends McpWildcard>(filter: W, handler: (request: {
|
|
135
|
+
method: string;
|
|
136
|
+
params: Record<string, unknown>;
|
|
137
|
+
}, extra: McpExtraFor<W>, next: () => Promise<McpResultFor<W>>) => Promise<unknown> | unknown): this;
|
|
138
|
+
/**
|
|
139
|
+
* Register MCP protocol-level middleware with a method filter.
|
|
140
|
+
* Filter can be an exact method (`"tools/call"`), wildcard (`"tools/*"`),
|
|
141
|
+
* category (`"request"` | `"notification"`), or an array of those.
|
|
142
|
+
*/
|
|
143
|
+
mcpMiddleware(filter: McpMiddlewareFilter, handler: McpMiddlewareFn): this;
|
|
144
|
+
private applyMcpMiddleware;
|
|
145
|
+
connect(transport: Parameters<typeof McpServerBase.prototype.connect>[0]): Promise<void>;
|
|
146
|
+
/**
|
|
147
|
+
* Per-request stateless connect. The SDK's `Protocol` only allows one
|
|
148
|
+
* transport per instance, so we can't reuse this `McpServer` across
|
|
149
|
+
* concurrent requests. The SDK's idiomatic fix is a `() => McpServer`
|
|
150
|
+
* factory, but that would break Skybridge's singleton API — so instead
|
|
151
|
+
* we build a fresh underlying `Server` per request and share the main
|
|
152
|
+
* server's handler maps by reference. The cast is unavoidable: there's
|
|
153
|
+
* no public API to inject handler maps. `getHandlerMaps` validates the
|
|
154
|
+
* read side and fails fast on SDK field renames.
|
|
155
|
+
*/
|
|
156
|
+
connectStatelessTransport(transport: Parameters<typeof McpServerBase.prototype.connect>[0]): Promise<void>;
|
|
157
|
+
run(): Promise<void>;
|
|
158
|
+
private enforceOneToolPerView;
|
|
159
|
+
private registerViewResources;
|
|
160
|
+
private registerViewResource;
|
|
161
|
+
private wrapHandler;
|
|
162
|
+
private computeViewVersionParam;
|
|
163
|
+
private lookupViewFile;
|
|
164
|
+
private lookupDistFile;
|
|
165
|
+
private readManifest;
|
|
166
|
+
registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends {
|
|
167
|
+
content?: HandlerContent;
|
|
168
|
+
}>(config: ToolConfig<InputArgs> & {
|
|
169
|
+
name: TName;
|
|
170
|
+
}, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
171
|
+
registerTool<InputArgs extends ZodRawShapeCompat>(config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs>): this;
|
|
172
|
+
}
|
|
173
|
+
export {};
|
|
@@ -0,0 +1,436 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import { readFileSync } from "node:fs";
|
|
3
|
+
import http from "node:http";
|
|
4
|
+
import path from "node:path";
|
|
5
|
+
import { Server as SdkServer, } from "@modelcontextprotocol/sdk/server/index.js";
|
|
6
|
+
import { McpServer as McpServerBase } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
7
|
+
import { mergeWith, union } from "es-toolkit";
|
|
8
|
+
import { createApp } from "./express.js";
|
|
9
|
+
import { createMiddlewareEntry } from "./metric.js";
|
|
10
|
+
import { buildMiddlewareChain, getHandlerMaps } from "./middleware.js";
|
|
11
|
+
import { templateHelper } from "./templateHelper.js";
|
|
12
|
+
const mergeWithUnion = (target, source) => {
|
|
13
|
+
return mergeWith(target, source, (targetVal, sourceVal) => {
|
|
14
|
+
if (Array.isArray(targetVal) && Array.isArray(sourceVal)) {
|
|
15
|
+
return union(targetVal, sourceVal);
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
};
|
|
19
|
+
export function normalizeContent(content) {
|
|
20
|
+
if (content === undefined) {
|
|
21
|
+
return [];
|
|
22
|
+
}
|
|
23
|
+
if (typeof content === "string") {
|
|
24
|
+
return [{ type: "text", text: content }];
|
|
25
|
+
}
|
|
26
|
+
if (Array.isArray(content)) {
|
|
27
|
+
return content;
|
|
28
|
+
}
|
|
29
|
+
return [content];
|
|
30
|
+
}
|
|
31
|
+
const McpServerBaseOmitted = McpServerBase;
|
|
32
|
+
export class McpServer extends McpServerBaseOmitted {
|
|
33
|
+
express;
|
|
34
|
+
customMiddleware = [];
|
|
35
|
+
customErrorMiddleware = [];
|
|
36
|
+
mcpMiddlewareEntries = [];
|
|
37
|
+
mcpMiddlewareApplied = false;
|
|
38
|
+
claimedViews = new Map();
|
|
39
|
+
serverInfo;
|
|
40
|
+
serverOptions;
|
|
41
|
+
constructor(serverInfo, options) {
|
|
42
|
+
super(serverInfo, options);
|
|
43
|
+
this.serverInfo = serverInfo;
|
|
44
|
+
this.serverOptions = options;
|
|
45
|
+
}
|
|
46
|
+
use(pathOrHandler, ...handlers) {
|
|
47
|
+
if (typeof pathOrHandler === "string") {
|
|
48
|
+
this.customMiddleware.push({
|
|
49
|
+
path: pathOrHandler,
|
|
50
|
+
handlers,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
this.customMiddleware.push({
|
|
55
|
+
handlers: [pathOrHandler, ...handlers],
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
useOnError(pathOrHandler, ...handlers) {
|
|
61
|
+
if (typeof pathOrHandler === "string") {
|
|
62
|
+
this.customErrorMiddleware.push({ path: pathOrHandler, handlers });
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
this.customErrorMiddleware.push({
|
|
66
|
+
handlers: [pathOrHandler, ...handlers],
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
return this;
|
|
70
|
+
}
|
|
71
|
+
mcpMiddleware(filterOrHandler,
|
|
72
|
+
// biome-ignore lint/suspicious/noExplicitAny: overloads narrow the handler type at call sites; implementation must accept all variants
|
|
73
|
+
maybeHandler) {
|
|
74
|
+
if (this.mcpMiddlewareApplied) {
|
|
75
|
+
throw new Error("Cannot register MCP middleware after run() or connect() has been called");
|
|
76
|
+
}
|
|
77
|
+
const handler = maybeHandler;
|
|
78
|
+
if (typeof filterOrHandler === "function") {
|
|
79
|
+
this.mcpMiddlewareEntries.push({
|
|
80
|
+
filter: null,
|
|
81
|
+
handler: filterOrHandler,
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
else if (handler) {
|
|
85
|
+
this.mcpMiddlewareEntries.push({
|
|
86
|
+
filter: filterOrHandler,
|
|
87
|
+
handler,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
else {
|
|
91
|
+
throw new Error("mcpMiddleware requires a handler function when a filter is provided");
|
|
92
|
+
}
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
applyMcpMiddleware() {
|
|
96
|
+
if (this.mcpMiddlewareApplied) {
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
this.mcpMiddlewareApplied = true;
|
|
100
|
+
const monitoringEntry = createMiddlewareEntry();
|
|
101
|
+
const entries = monitoringEntry
|
|
102
|
+
? [monitoringEntry, ...this.mcpMiddlewareEntries]
|
|
103
|
+
: this.mcpMiddlewareEntries;
|
|
104
|
+
if (entries.length === 0) {
|
|
105
|
+
return;
|
|
106
|
+
}
|
|
107
|
+
const { requestHandlers, notificationHandlers } = getHandlerMaps(this.server);
|
|
108
|
+
const instrumentMap = (map, isNotification) => {
|
|
109
|
+
for (const [method, handler] of map) {
|
|
110
|
+
map.set(method, buildMiddlewareChain(method, isNotification, handler, entries));
|
|
111
|
+
}
|
|
112
|
+
const originalSet = map.set.bind(map);
|
|
113
|
+
map.set = (method, handler) => originalSet(method, buildMiddlewareChain(method, isNotification, handler, entries));
|
|
114
|
+
};
|
|
115
|
+
instrumentMap(requestHandlers, false);
|
|
116
|
+
instrumentMap(notificationHandlers, true);
|
|
117
|
+
}
|
|
118
|
+
async connect(transport) {
|
|
119
|
+
this.applyMcpMiddleware();
|
|
120
|
+
return McpServerBase.prototype.connect.call(this, transport);
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Per-request stateless connect. The SDK's `Protocol` only allows one
|
|
124
|
+
* transport per instance, so we can't reuse this `McpServer` across
|
|
125
|
+
* concurrent requests. The SDK's idiomatic fix is a `() => McpServer`
|
|
126
|
+
* factory, but that would break Skybridge's singleton API — so instead
|
|
127
|
+
* we build a fresh underlying `Server` per request and share the main
|
|
128
|
+
* server's handler maps by reference. The cast is unavoidable: there's
|
|
129
|
+
* no public API to inject handler maps. `getHandlerMaps` validates the
|
|
130
|
+
* read side and fails fast on SDK field renames.
|
|
131
|
+
*/
|
|
132
|
+
async connectStatelessTransport(transport) {
|
|
133
|
+
this.applyMcpMiddleware();
|
|
134
|
+
const { requestHandlers, notificationHandlers } = getHandlerMaps(this.server);
|
|
135
|
+
const fresh = new SdkServer(this.serverInfo, this.serverOptions);
|
|
136
|
+
const target = fresh;
|
|
137
|
+
target._requestHandlers = requestHandlers;
|
|
138
|
+
target._notificationHandlers = notificationHandlers;
|
|
139
|
+
await fresh.connect(transport);
|
|
140
|
+
}
|
|
141
|
+
async run() {
|
|
142
|
+
this.applyMcpMiddleware();
|
|
143
|
+
const httpServer = http.createServer();
|
|
144
|
+
if (!this.express) {
|
|
145
|
+
this.express = await createApp({
|
|
146
|
+
mcpServer: this,
|
|
147
|
+
httpServer,
|
|
148
|
+
customMiddleware: this.customMiddleware,
|
|
149
|
+
errorMiddleware: this.customErrorMiddleware,
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
httpServer.on("request", this.express);
|
|
153
|
+
await new Promise((resolve, reject) => {
|
|
154
|
+
httpServer.on("error", (error) => {
|
|
155
|
+
console.error("Failed to start server:", error);
|
|
156
|
+
reject(error);
|
|
157
|
+
});
|
|
158
|
+
const port = parseInt(process.env.__PORT ?? "3000", 10);
|
|
159
|
+
httpServer.listen(port, () => {
|
|
160
|
+
resolve();
|
|
161
|
+
});
|
|
162
|
+
});
|
|
163
|
+
const shutdown = () => {
|
|
164
|
+
// Drop both handlers so a second signal falls through to Node's default
|
|
165
|
+
// (force-quit on a second Ctrl+C while drain is hanging).
|
|
166
|
+
process.off("SIGTERM", shutdown);
|
|
167
|
+
process.off("SIGINT", shutdown);
|
|
168
|
+
httpServer.close(() => process.exit(0));
|
|
169
|
+
// Force exit if connections don't drain in time so the port is still
|
|
170
|
+
// released promptly (e.g. for nodemon restarts).
|
|
171
|
+
setTimeout(() => process.exit(0), 3000).unref();
|
|
172
|
+
};
|
|
173
|
+
process.on("SIGTERM", shutdown);
|
|
174
|
+
process.on("SIGINT", shutdown);
|
|
175
|
+
}
|
|
176
|
+
enforceOneToolPerView(component, toolName) {
|
|
177
|
+
const existingTool = this.claimedViews.get(component);
|
|
178
|
+
if (existingTool) {
|
|
179
|
+
throw new Error(`skybridge: view "${component}" is already used by tool "${existingTool}". Tool "${toolName}" cannot also reference it — each view backs exactly one tool.`);
|
|
180
|
+
}
|
|
181
|
+
this.claimedViews.set(component, toolName);
|
|
182
|
+
}
|
|
183
|
+
registerViewResources(toolName, view, toolMeta) {
|
|
184
|
+
const hosts = view.hosts ?? ["apps-sdk", "mcp-app"];
|
|
185
|
+
// Append a content-derived version param so hosts (e.g. ChatGPT) bust
|
|
186
|
+
// their cache when the bundle changes, but keep the URI stable across
|
|
187
|
+
// `tools/list` calls when the bundle hasn't changed.
|
|
188
|
+
const versionParam = this.computeViewVersionParam(view.component);
|
|
189
|
+
if (hosts.includes("apps-sdk")) {
|
|
190
|
+
const viewResource = {
|
|
191
|
+
hostType: "apps-sdk",
|
|
192
|
+
uri: `ui://views/apps-sdk/${view.component}.html${versionParam}`,
|
|
193
|
+
mimeType: "text/html+skybridge",
|
|
194
|
+
buildContentMeta: ({ resourceDomains, connectDomains, domain }, overrides) => {
|
|
195
|
+
const defaults = {
|
|
196
|
+
"openai/widgetCSP": {
|
|
197
|
+
resource_domains: resourceDomains,
|
|
198
|
+
connect_domains: connectDomains,
|
|
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,
|
|
243
|
+
},
|
|
244
|
+
};
|
|
245
|
+
const fromView = {
|
|
246
|
+
ui: {
|
|
247
|
+
...(view.description && { description: view.description }),
|
|
248
|
+
...(view.prefersBorder !== undefined && {
|
|
249
|
+
prefersBorder: view.prefersBorder,
|
|
250
|
+
}),
|
|
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
|
+
},
|
|
270
|
+
};
|
|
271
|
+
const base = mergeWithUnion(mergeWithUnion(defaults, fromView), {
|
|
272
|
+
ui: overrides,
|
|
273
|
+
});
|
|
274
|
+
if (view._meta) {
|
|
275
|
+
return { ...base, ...view._meta };
|
|
276
|
+
}
|
|
277
|
+
return base;
|
|
278
|
+
},
|
|
279
|
+
};
|
|
280
|
+
this.registerViewResource({
|
|
281
|
+
name: toolName,
|
|
282
|
+
viewResource,
|
|
283
|
+
view,
|
|
284
|
+
});
|
|
285
|
+
// @ts-expect-error - For backwards compatibility with Claude current implementation of the specs
|
|
286
|
+
toolMeta["ui/resourceUri"] = viewResource.uri;
|
|
287
|
+
toolMeta.ui = { resourceUri: viewResource.uri };
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
registerViewResource({ name, viewResource, view, }) {
|
|
291
|
+
const { hostType, uri: viewUri, mimeType, buildContentMeta } = viewResource;
|
|
292
|
+
this.registerResource(name, viewUri, { description: view.description }, async (uri, extra) => {
|
|
293
|
+
const isProduction = process.env.NODE_ENV === "production";
|
|
294
|
+
const isClaude = extra?.requestInfo?.headers?.["user-agent"] === "Claude-User";
|
|
295
|
+
const headers = extra?.requestInfo?.headers || {};
|
|
296
|
+
const header = (key) => {
|
|
297
|
+
const val = headers[key];
|
|
298
|
+
return Array.isArray(val) ? val[0] : val;
|
|
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
|
+
}
|
|
321
|
+
const html = isProduction
|
|
322
|
+
? templateHelper.renderProduction({
|
|
323
|
+
hostType,
|
|
324
|
+
serverUrl,
|
|
325
|
+
viewFile: this.lookupViewFile(view.component),
|
|
326
|
+
styleFile: this.lookupDistFile("style.css") ?? "",
|
|
327
|
+
})
|
|
328
|
+
: templateHelper.renderDevelopment({
|
|
329
|
+
hostType,
|
|
330
|
+
serverUrl,
|
|
331
|
+
viewName: view.component,
|
|
332
|
+
});
|
|
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
|
+
return {
|
|
360
|
+
contents: [
|
|
361
|
+
{ uri: uri.href, mimeType, text: html, _meta: contentMeta },
|
|
362
|
+
],
|
|
363
|
+
};
|
|
364
|
+
});
|
|
365
|
+
}
|
|
366
|
+
wrapHandler(cb, { attachViewUUID }) {
|
|
367
|
+
return async (args, extra) => {
|
|
368
|
+
const result = await cb(args, extra);
|
|
369
|
+
return {
|
|
370
|
+
...result,
|
|
371
|
+
content: normalizeContent(result.content),
|
|
372
|
+
...(attachViewUUID && {
|
|
373
|
+
_meta: {
|
|
374
|
+
...result._meta,
|
|
375
|
+
viewUUID: crypto.randomUUID(),
|
|
376
|
+
},
|
|
377
|
+
}),
|
|
378
|
+
};
|
|
379
|
+
};
|
|
380
|
+
}
|
|
381
|
+
computeViewVersionParam(viewName) {
|
|
382
|
+
if (process.env.NODE_ENV !== "production") {
|
|
383
|
+
return "";
|
|
384
|
+
}
|
|
385
|
+
try {
|
|
386
|
+
const viewFile = this.lookupViewFile(viewName);
|
|
387
|
+
const styleFile = this.lookupDistFile("style.css") ?? "";
|
|
388
|
+
const hash = crypto
|
|
389
|
+
.createHash("sha256")
|
|
390
|
+
.update(viewFile)
|
|
391
|
+
.update("\0")
|
|
392
|
+
.update(styleFile)
|
|
393
|
+
.digest("hex")
|
|
394
|
+
.slice(0, 8);
|
|
395
|
+
return `?v=${hash}`;
|
|
396
|
+
}
|
|
397
|
+
catch {
|
|
398
|
+
return "";
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
lookupViewFile(viewName) {
|
|
402
|
+
const manifest = this.readManifest();
|
|
403
|
+
for (const entry of Object.values(manifest)) {
|
|
404
|
+
if (entry?.isEntry && entry.name === viewName && entry.file) {
|
|
405
|
+
return entry.file;
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
throw new Error(`View "${viewName}" not found in Vite manifest. Did the build complete successfully? Look for an entry with name "${viewName}" in dist/assets/.vite/manifest.json.`);
|
|
409
|
+
}
|
|
410
|
+
lookupDistFile(key) {
|
|
411
|
+
const manifest = this.readManifest();
|
|
412
|
+
return manifest[key]?.file;
|
|
413
|
+
}
|
|
414
|
+
readManifest() {
|
|
415
|
+
return JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
416
|
+
}
|
|
417
|
+
registerTool(...args) {
|
|
418
|
+
const baseFn = McpServerBase.prototype.registerTool;
|
|
419
|
+
if (typeof args[0] === "string") {
|
|
420
|
+
baseFn.call(this, args[0], args[1], args[2]);
|
|
421
|
+
return this;
|
|
422
|
+
}
|
|
423
|
+
const config = args[0];
|
|
424
|
+
const cb = args[1];
|
|
425
|
+
const { name, view, _meta: userToolMeta, ...toolFields } = config;
|
|
426
|
+
const toolMeta = { ...userToolMeta };
|
|
427
|
+
if (view) {
|
|
428
|
+
this.enforceOneToolPerView(view.component, name);
|
|
429
|
+
this.registerViewResources(name, view, toolMeta);
|
|
430
|
+
}
|
|
431
|
+
const wrappedCb = this.wrapHandler(cb, { attachViewUUID: Boolean(view) });
|
|
432
|
+
baseFn.call(this, name, { ...toolFields, _meta: toolMeta }, wrappedCb);
|
|
433
|
+
return this;
|
|
434
|
+
}
|
|
435
|
+
}
|
|
436
|
+
//# sourceMappingURL=server.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,MAAM,MAAM,aAAa,CAAC;AACjC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,WAAW,CAAC;AAK7B,OAAO,EACL,MAAM,IAAI,SAAS,GAEpB,MAAM,2CAA2C,CAAC;AACnD,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,yCAAy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AAE,YAAY,EAAE,GAAG,UAAU,EAAE,GAAG,MAAM,CAAC;QAElE,MAAM,QAAQ,GAAqB,EAAE,GAAG,YAAY,EAAE,CAAC;QAEvD,IAAI,IAAI,EAAE,CAAC;YACT,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;YACjD,IAAI,CAAC,qBAAqB,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;QACnD,CAAC;QAED,MAAM,SAAS,GAAG,IAAI,CAAC,WAAW,CAAC,EAAE,EAAE,EAAE,cAAc,EAAE,OAAO,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;QAE1E,MAAM,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,GAAG,UAAU,EAAE,KAAK,EAAE,QAAQ,EAAE,EAAE,SAAS,CAAC,CAAC;QAEvE,OAAO,IAAI,CAAC;IACd,CAAC;CACF"}
|
|
@@ -1,14 +1,17 @@
|
|
|
1
|
+
import type { ViewHostType } from "./server.js";
|
|
1
2
|
declare class TemplateHelper {
|
|
2
3
|
private templateCache;
|
|
3
4
|
private loadTemplate;
|
|
4
5
|
renderProduction(data: {
|
|
6
|
+
hostType: ViewHostType;
|
|
5
7
|
serverUrl: string;
|
|
6
|
-
|
|
8
|
+
viewFile: string;
|
|
7
9
|
styleFile: string;
|
|
8
10
|
}): string;
|
|
9
11
|
renderDevelopment(data: {
|
|
12
|
+
hostType: ViewHostType;
|
|
10
13
|
serverUrl: string;
|
|
11
|
-
|
|
14
|
+
viewName: string;
|
|
12
15
|
}): string;
|
|
13
16
|
}
|
|
14
17
|
export declare const templateHelper: TemplateHelper;
|