skybridge 0.0.0-dev.f76ccdc → 0.0.0-dev.f792261
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 +73 -0
- package/dist/cli/use-nodemon.js.map +1 -0
- package/dist/cli/use-open-browser.d.ts +1 -0
- package/dist/cli/use-open-browser.js +44 -0
- package/dist/cli/use-open-browser.js.map +1 -0
- package/dist/cli/use-tunnel.d.ts +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 +102 -0
- package/dist/commands/build.js.map +1 -0
- package/dist/commands/dev.d.ts +12 -0
- package/dist/commands/dev.js +80 -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 +11 -0
- package/dist/server/express.js +101 -0
- package/dist/server/express.js.map +1 -0
- package/dist/server/express.test.js +430 -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 +196 -0
- package/dist/server/server.js +468 -0
- package/dist/server/server.js.map +1 -0
- package/dist/{src/server → server}/templateHelper.d.ts +5 -4
- package/dist/server/templateHelper.js +11 -0
- package/dist/server/templateHelper.js.map +1 -0
- package/dist/server/templates.generated.d.ts +4 -0
- package/dist/server/templates.generated.js +47 -0
- package/dist/server/templates.generated.js.map +1 -0
- package/dist/server/tunnel-proxy-router.d.ts +7 -0
- package/dist/server/tunnel-proxy-router.js +110 -0
- package/dist/server/tunnel-proxy-router.js.map +1 -0
- package/dist/server/tunnel-proxy-router.test.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 +3 -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 +96 -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 +131 -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 +263 -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 +111 -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/web/hooks/use-call-tool.test.js +186 -0
- 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.d.ts +2 -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 +156 -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 +82 -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 +0 -29
- 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 -54
- package/dist/src/web/hooks/use-call-tool.js +0 -44
- package/dist/src/web/hooks/use-call-tool.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.test.js +0 -66
- 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.d.ts +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 -109
- 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
|
@@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CAAC;gBACH,CAAC;YACH,CAAC;YAAC,MAAM,CAAC;gBACP,8DAA8D;YAChE,CAAC;YAED,uEAAuE;YACvE,gEAAgE;YAChE,qEAAqE;YACrE,4CAA4C;YAC5C,MAAM,KAAK,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACzB,OACE,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,kBAAkB;gBAC3D,IAAI,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,IAAI,EACzB,CAAC;gBACD,MAAM,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;YAC9C,CAAC;YACD,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;YACxE,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,aAAa,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CACpD,qBAAqB,CACtB,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { EventEmitter } from \"node:events\";\nimport http from \"node:http\";\nimport { Readable } from \"node:stream\";\nimport express from \"express\";\nimport { afterEach, describe, expect, it, vi } from \"vitest\";\nimport { startTunnelControlServer } from \"../cli/tunnel-control-server.js\";\nimport { createTunnelProxyRouter } from \"./tunnel-proxy-router.js\";\n\ntype FakeChild = EventEmitter & {\n stdout: Readable;\n stderr: Readable;\n kill: ReturnType<typeof vi.fn<() => boolean>>;\n};\n\nfunction makeFakeChild(): FakeChild {\n const child = new EventEmitter() as FakeChild;\n child.stdout = new Readable({ read() {} });\n child.stderr = new Readable({ read() {} });\n child.kill = vi.fn<() => boolean>(() => true);\n return child;\n}\n\nasync function listen(handler: http.RequestListener) {\n const server = http.createServer(handler);\n await new Promise<void>((resolve) => server.listen(0, \"127.0.0.1\", resolve));\n const port = (server.address() as { port: number }).port;\n return { port, server };\n}\n\ntype Cleanup = () => Promise<void> | void;\nconst cleanups: Cleanup[] = [];\n\nafterEach(async () => {\n while (cleanups.length > 0) {\n const cleanup = cleanups.pop();\n if (cleanup) {\n await cleanup();\n }\n }\n});\n\nasync function startProxy(controlPort: number) {\n const app = express();\n app.use(createTunnelProxyRouter(controlPort));\n const { port, server } = await listen(app);\n cleanups.push(\n () =>\n new Promise<void>((resolve) => {\n server.closeAllConnections?.();\n server.close(() => resolve());\n }),\n );\n return { port, server };\n}\n\nasync function startControl() {\n const child = makeFakeChild();\n const control = await startTunnelControlServer(() => 3000, {\n spawn: () => child,\n });\n cleanups.push(() => control.close());\n return { control, child };\n}\n\ndescribe(\"createTunnelProxyRouter\", () => {\n describe(\"POST /__skybridge/tunnel\", () => {\n it(\"forwards to upstream and returns the upstream JSON\", async () => {\n const { control } = await startControl();\n const { port } = await startProxy(control.port);\n\n const res = await fetch(`http://127.0.0.1:${port}/__skybridge/tunnel`, {\n method: \"POST\",\n });\n\n expect(res.status).toBe(200);\n expect(res.headers.get(\"content-type\")).toMatch(/application\\/json/);\n expect(await res.json()).toEqual({\n status: \"starting\",\n message: \"Starting tunnel…\",\n });\n expect(control.manager.getState().status).toBe(\"starting\");\n });\n\n it(\"returns 502 when upstream is unavailable\", async () => {\n // Pick a port nothing is listening on by starting+stopping a server.\n const probe = http.createServer();\n await new Promise<void>((resolve) =>\n probe.listen(0, \"127.0.0.1\", resolve),\n );\n const deadPort = (probe.address() as { port: number }).port;\n await new Promise<void>((resolve) => probe.close(() => resolve()));\n\n const { port } = await startProxy(deadPort);\n\n const res = await fetch(`http://127.0.0.1:${port}/__skybridge/tunnel`, {\n method: \"POST\",\n });\n expect(res.status).toBe(502);\n const body = (await res.json()) as { status: string; message: string };\n expect(body.status).toBe(\"error\");\n expect(typeof body.message).toBe(\"string\");\n });\n });\n\n describe(\"DELETE /__skybridge/tunnel\", () => {\n it(\"forwards to upstream and returns the upstream JSON\", async () => {\n const { control, child } = await startControl();\n const { port } = await startProxy(control.port);\n\n // First start the tunnel so DELETE has something to stop.\n await fetch(`http://127.0.0.1:${port}/__skybridge/tunnel`, {\n method: \"POST\",\n });\n\n const res = await fetch(`http://127.0.0.1:${port}/__skybridge/tunnel`, {\n method: \"DELETE\",\n });\n\n expect(res.status).toBe(200);\n expect(await res.json()).toEqual({ status: \"idle\" });\n expect(child.kill).toHaveBeenCalled();\n });\n\n it(\"returns 502 when upstream is unavailable\", async () => {\n const probe = http.createServer();\n await new Promise<void>((resolve) =>\n probe.listen(0, \"127.0.0.1\", resolve),\n );\n const deadPort = (probe.address() as { port: number }).port;\n await new Promise<void>((resolve) => probe.close(() => resolve()));\n\n const { port } = await startProxy(deadPort);\n\n const res = await fetch(`http://127.0.0.1:${port}/__skybridge/tunnel`, {\n method: \"DELETE\",\n });\n expect(res.status).toBe(502);\n });\n });\n\n describe(\"GET /__skybridge/tunnel/events\", () => {\n it(\"pipes the upstream SSE stream through to the client\", async () => {\n const { control, child } = await startControl();\n const { port } = await startProxy(control.port);\n\n // Get the manager into a known state so the initial SSE frame is\n // deterministic.\n await fetch(`http://127.0.0.1:${port}/__skybridge/tunnel`, {\n method: \"POST\",\n });\n child.stdout.emit(\n \"data\",\n Buffer.from(\n \"Forwarding: https://abc.tunnel.example -> http://localhost:3000\\n\",\n ),\n );\n\n const res = await fetch(\n `http://127.0.0.1:${port}/__skybridge/tunnel/events`,\n );\n\n expect(res.status).toBe(200);\n expect(res.headers.get(\"content-type\")).toMatch(/text\\/event-stream/);\n expect(res.headers.get(\"cache-control\")).toMatch(/no-cache/);\n\n const body = res.body;\n if (!body) {\n throw new Error(\"expected response body\");\n }\n const reader = body.getReader();\n const { value } = await reader.read();\n const chunk = new TextDecoder().decode(value);\n\n expect(chunk).toContain(\"event: state\");\n expect(chunk).toContain('\"status\":\"connected\"');\n expect(chunk).toContain('\"url\":\"https://abc.tunnel.example\"');\n\n await reader.cancel();\n });\n\n it(\"forwards subsequent state changes through the SSE stream\", async () => {\n const { control, child } = await startControl();\n const { port } = await startProxy(control.port);\n\n await fetch(`http://127.0.0.1:${port}/__skybridge/tunnel`, {\n method: \"POST\",\n });\n\n const res = await fetch(\n `http://127.0.0.1:${port}/__skybridge/tunnel/events`,\n );\n const body = res.body;\n if (!body) {\n throw new Error(\"expected response body\");\n }\n const reader = body.getReader();\n const decoder = new TextDecoder();\n\n // Drain the initial \"starting\" frame.\n const first = await reader.read();\n expect(decoder.decode(first.value)).toContain('\"status\":\"starting\"');\n\n // Now drive a state change on the manager and read the next frame.\n child.stdout.emit(\n \"data\",\n Buffer.from(\n \"Forwarding: https://abc.tunnel.example -> http://localhost:3000\\n\",\n ),\n );\n\n let combined = \"\";\n // Reads may chunk arbitrarily, so accumulate until we see the connected\n // event or hit a sane cap.\n for (let i = 0; i < 5; i++) {\n const { value, done } = await reader.read();\n if (done) {\n break;\n }\n combined += decoder.decode(value);\n if (combined.includes('\"status\":\"connected\"')) {\n break;\n }\n }\n expect(combined).toContain('\"status\":\"connected\"');\n expect(combined).toContain('\"url\":\"https://abc.tunnel.example\"');\n\n await reader.cancel();\n });\n\n it(\"returns 502 when upstream is unavailable\", async () => {\n const probe = http.createServer();\n await new Promise<void>((resolve) =>\n probe.listen(0, \"127.0.0.1\", resolve),\n );\n const deadPort = (probe.address() as { port: number }).port;\n await new Promise<void>((resolve) => probe.close(() => resolve()));\n\n const { port } = await startProxy(deadPort);\n\n const res = await fetch(\n `http://127.0.0.1:${port}/__skybridge/tunnel/events`,\n );\n expect(res.status).toBe(502);\n const body = (await res.json()) as { status: string };\n expect(body.status).toBe(\"error\");\n });\n\n it(\"aborts the upstream connection when the proxy server is closed mid-stream\", async () => {\n const { control } = await startControl();\n const { port, server } = await startProxy(control.port);\n\n await fetch(`http://127.0.0.1:${port}/__skybridge/tunnel`, {\n method: \"POST\",\n });\n\n // Snapshot the manager's listener counts before the SSE subscription so\n // we can verify the proxy disconnected from upstream after shutdown.\n const baseStateListeners = control.manager.listenerCount(\"state\");\n const baseActivityListeners = control.manager.listenerCount(\"activity\");\n\n const res = await fetch(\n `http://127.0.0.1:${port}/__skybridge/tunnel/events`,\n );\n const body = res.body;\n if (!body) {\n throw new Error(\"expected response body\");\n }\n const reader = body.getReader();\n // Drain the first frame to confirm the stream is live and the upstream\n // SSE handler has subscribed to the manager.\n await reader.read();\n expect(control.manager.listenerCount(\"state\")).toBe(\n baseStateListeners + 1,\n );\n\n // Close the proxy server, destroying in-flight responses. The proxy's\n // req.on(\"close\", ...) should fire and abort the upstream fetch.\n server.closeAllConnections?.();\n await new Promise<void>((resolve) => server.close(() => resolve()));\n\n // The client-side stream is dead — drain or fail, either is acceptable.\n try {\n while (true) {\n const { done } = await reader.read();\n if (done) {\n break;\n }\n }\n } catch {\n // expected: socket terminated when proxy server was destroyed\n }\n\n // Wait briefly for the upstream's req.on(\"close\") to fire, then assert\n // the manager listeners were detached. This is the load-bearing\n // verification: it proves the proxy's AbortController propagated and\n // upstream cleaned up its SSE subscription.\n const start = Date.now();\n while (\n control.manager.listenerCount(\"state\") > baseStateListeners &&\n Date.now() - start < 1000\n ) {\n await new Promise((r) => setTimeout(r, 20));\n }\n expect(control.manager.listenerCount(\"state\")).toBe(baseStateListeners);\n expect(control.manager.listenerCount(\"activity\")).toBe(\n baseActivityListeners,\n );\n });\n });\n});\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type http from "node:http";
|
|
2
|
+
import { type Router } from "express";
|
|
3
|
+
/**
|
|
4
|
+
* Vite dev-server middleware for view assets.
|
|
5
|
+
*
|
|
6
|
+
* MUST be mounted at the Express app root so Vite can intercept
|
|
7
|
+
* `/@vite/client`, `/@react-refresh`, and `/_skybridge/view/...` imports:
|
|
8
|
+
*
|
|
9
|
+
* const app = express();
|
|
10
|
+
* if (env.NODE_ENV !== "production") {
|
|
11
|
+
* app.use(await viewsDevServer(httpServer));
|
|
12
|
+
* }
|
|
13
|
+
*/
|
|
14
|
+
export declare const viewsDevServer: (httpServer: http.Server) => Promise<Router>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import path from "node:path";
|
|
2
|
+
import cors from "cors";
|
|
3
|
+
import express, {} from "express";
|
|
4
|
+
import { assetBaseUrlTransformPlugin } from "./asset-base-url-transform-plugin.js";
|
|
5
|
+
/**
|
|
6
|
+
* Vite dev-server middleware for view assets.
|
|
7
|
+
*
|
|
8
|
+
* MUST be mounted at the Express app root so Vite can intercept
|
|
9
|
+
* `/@vite/client`, `/@react-refresh`, and `/_skybridge/view/...` imports:
|
|
10
|
+
*
|
|
11
|
+
* const app = express();
|
|
12
|
+
* if (env.NODE_ENV !== "production") {
|
|
13
|
+
* app.use(await viewsDevServer(httpServer));
|
|
14
|
+
* }
|
|
15
|
+
*/
|
|
16
|
+
export const viewsDevServer = async (httpServer) => {
|
|
17
|
+
const router = express.Router();
|
|
18
|
+
const { createServer, loadConfigFromFile } = await import("vite");
|
|
19
|
+
const root = process.cwd();
|
|
20
|
+
const configFile = path.join(root, "vite.config.ts");
|
|
21
|
+
const configResult = await loadConfigFromFile({ command: "serve", mode: "development" }, configFile, root);
|
|
22
|
+
const { build, preview, plugins: userPlugins = [], ...devConfig } = configResult?.config || {};
|
|
23
|
+
const vite = await createServer({
|
|
24
|
+
...devConfig,
|
|
25
|
+
// Pass `false` so Vite skips re-resolving a config file — we already
|
|
26
|
+
// loaded and spread the user's config above.
|
|
27
|
+
configFile: false,
|
|
28
|
+
appType: "custom",
|
|
29
|
+
server: {
|
|
30
|
+
allowedHosts: true,
|
|
31
|
+
middlewareMode: true,
|
|
32
|
+
hmr: {
|
|
33
|
+
server: httpServer,
|
|
34
|
+
},
|
|
35
|
+
},
|
|
36
|
+
root,
|
|
37
|
+
// optimizeDeps is set by the skybridge Vite plugin (entries + include)
|
|
38
|
+
// so it can derive the view glob from `viewsDir`.
|
|
39
|
+
plugins: [...userPlugins, assetBaseUrlTransformPlugin()],
|
|
40
|
+
});
|
|
41
|
+
router.use(cors());
|
|
42
|
+
router.use("/", vite.middlewares);
|
|
43
|
+
return router;
|
|
44
|
+
};
|
|
45
|
+
//# sourceMappingURL=viewsDevServer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"viewsDevServer.js","sourceRoot":"","sources":["../../src/server/viewsDevServer.ts"],"names":[],"mappings":"AACA,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,EAAE,EAAe,MAAM,SAAS,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,sCAAsC,CAAC;AAEnF;;;;;;;;;;GAUG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,KAAK,EACjC,UAAuB,EACN,EAAE;IACnB,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEhC,MAAM,EAAE,YAAY,EAAE,kBAAkB,EAAE,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC;IAElE,MAAM,IAAI,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC3B,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,gBAAgB,CAAC,CAAC;IAErD,MAAM,YAAY,GAAG,MAAM,kBAAkB,CAC3C,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,aAAa,EAAE,EACzC,UAAU,EACV,IAAI,CACL,CAAC;IAEF,MAAM,EACJ,KAAK,EACL,OAAO,EACP,OAAO,EAAE,WAAW,GAAG,EAAE,EACzB,GAAG,SAAS,EACb,GAAG,YAAY,EAAE,MAAM,IAAI,EAAE,CAAC;IAE/B,MAAM,IAAI,GAAG,MAAM,YAAY,CAAC;QAC9B,GAAG,SAAS;QACZ,qEAAqE;QACrE,6CAA6C;QAC7C,UAAU,EAAE,KAAK;QACjB,OAAO,EAAE,QAAQ;QACjB,MAAM,EAAE;YACN,YAAY,EAAE,IAAI;YAClB,cAAc,EAAE,IAAI;YACpB,GAAG,EAAE;gBACH,MAAM,EAAE,UAAU;aACnB;SACF;QACD,IAAI;QACJ,uEAAuE;QACvE,kDAAkD;QAClD,OAAO,EAAE,CAAC,GAAG,WAAW,EAAE,2BAA2B,EAAE,CAAC;KACzD,CAAC,CAAC;IAEH,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IACnB,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;IAElC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC","sourcesContent":["import type http from \"node:http\";\nimport path from \"node:path\";\nimport cors from \"cors\";\nimport express, { type Router } from \"express\";\nimport { assetBaseUrlTransformPlugin } from \"./asset-base-url-transform-plugin.js\";\n\n/**\n * Vite dev-server middleware for view assets.\n *\n * MUST be mounted at the Express app root so Vite can intercept\n * `/@vite/client`, `/@react-refresh`, and `/_skybridge/view/...` imports:\n *\n * const app = express();\n * if (env.NODE_ENV !== \"production\") {\n * app.use(await viewsDevServer(httpServer));\n * }\n */\nexport const viewsDevServer = async (\n httpServer: http.Server,\n): Promise<Router> => {\n const router = express.Router();\n\n const { createServer, loadConfigFromFile } = await import(\"vite\");\n\n const root = process.cwd();\n const configFile = path.join(root, \"vite.config.ts\");\n\n const configResult = await loadConfigFromFile(\n { command: \"serve\", mode: \"development\" },\n configFile,\n root,\n );\n\n const {\n build,\n preview,\n plugins: userPlugins = [],\n ...devConfig\n } = configResult?.config || {};\n\n const vite = await createServer({\n ...devConfig,\n // Pass `false` so Vite skips re-resolving a config file — we already\n // loaded and spread the user's config above.\n configFile: false,\n appType: \"custom\",\n server: {\n allowedHosts: true,\n middlewareMode: true,\n hmr: {\n server: httpServer,\n },\n },\n root,\n // optimizeDeps is set by the skybridge Vite plugin (entries + include)\n // so it can derive the view glob from `viewsDir`.\n plugins: [...userPlugins, assetBaseUrlTransformPlugin()],\n });\n\n router.use(cors());\n router.use(\"/\", vite.middlewares);\n\n return router;\n};\n"]}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import { type MockInstance } from "vitest";
|
|
2
|
+
import { McpServer } from "../server/server.js";
|
|
3
|
+
export declare function createMockMcpServer(): {
|
|
4
|
+
server: McpServer;
|
|
5
|
+
mockRegisterResource: MockInstance<McpServer["registerResource"]>;
|
|
6
|
+
mockRegisterTool: MockInstance;
|
|
7
|
+
};
|
|
8
|
+
export declare function createTestServer(): McpServer<Record<never, import("../server/server.js").ToolDef<unknown, unknown, unknown>> & {
|
|
9
|
+
"search-trip": import("../server/server.js").ToolDef<{
|
|
10
|
+
destination: string;
|
|
11
|
+
departureDate?: string | undefined;
|
|
12
|
+
maxPrice?: number | undefined;
|
|
13
|
+
}, {
|
|
14
|
+
results: {
|
|
15
|
+
id: string;
|
|
16
|
+
name: string;
|
|
17
|
+
price: number;
|
|
18
|
+
}[];
|
|
19
|
+
totalCount: number;
|
|
20
|
+
}, unknown>;
|
|
21
|
+
} & {
|
|
22
|
+
"get-trip-details": import("../server/server.js").ToolDef<{
|
|
23
|
+
tripId: string;
|
|
24
|
+
}, {
|
|
25
|
+
name: string;
|
|
26
|
+
description: string;
|
|
27
|
+
images: string[];
|
|
28
|
+
}, unknown>;
|
|
29
|
+
} & {
|
|
30
|
+
"no-input-view": import("../server/server.js").ToolDef<{}, {}, unknown>;
|
|
31
|
+
} & {
|
|
32
|
+
"inferred-output-view": import("../server/server.js").ToolDef<{
|
|
33
|
+
query: string;
|
|
34
|
+
}, {
|
|
35
|
+
inferredResults: {
|
|
36
|
+
id: string;
|
|
37
|
+
score: number;
|
|
38
|
+
}[];
|
|
39
|
+
inferredCount: number;
|
|
40
|
+
}, unknown>;
|
|
41
|
+
} & {
|
|
42
|
+
"calculate-price": import("../server/server.js").ToolDef<{
|
|
43
|
+
tripId: string;
|
|
44
|
+
passengers: number;
|
|
45
|
+
}, {
|
|
46
|
+
totalPrice: number;
|
|
47
|
+
currency: string;
|
|
48
|
+
}, unknown>;
|
|
49
|
+
} & {
|
|
50
|
+
"inferred-tool": import("../server/server.js").ToolDef<{
|
|
51
|
+
itemId: string;
|
|
52
|
+
}, {
|
|
53
|
+
itemDetails: {
|
|
54
|
+
name: string;
|
|
55
|
+
available: boolean;
|
|
56
|
+
};
|
|
57
|
+
fetchedAt: string;
|
|
58
|
+
}, unknown>;
|
|
59
|
+
} & {
|
|
60
|
+
"view-with-metadata": import("../server/server.js").ToolDef<{
|
|
61
|
+
resourceId: string;
|
|
62
|
+
}, {
|
|
63
|
+
data: {
|
|
64
|
+
id: string;
|
|
65
|
+
loaded: boolean;
|
|
66
|
+
};
|
|
67
|
+
}, {
|
|
68
|
+
requestId: string;
|
|
69
|
+
timestamp: number;
|
|
70
|
+
cached: boolean;
|
|
71
|
+
}>;
|
|
72
|
+
} & {
|
|
73
|
+
"tool-with-metadata": import("../server/server.js").ToolDef<{
|
|
74
|
+
query: string;
|
|
75
|
+
}, {
|
|
76
|
+
results: string[];
|
|
77
|
+
}, {
|
|
78
|
+
executionTime: number;
|
|
79
|
+
source: string;
|
|
80
|
+
}>;
|
|
81
|
+
} & {
|
|
82
|
+
"view-with-mixed-returns": import("../server/server.js").ToolDef<{
|
|
83
|
+
shouldSucceed: boolean;
|
|
84
|
+
}, {
|
|
85
|
+
error: string;
|
|
86
|
+
data?: undefined;
|
|
87
|
+
} | {
|
|
88
|
+
data: string;
|
|
89
|
+
error?: undefined;
|
|
90
|
+
}, {
|
|
91
|
+
processedAt: number;
|
|
92
|
+
region: string;
|
|
93
|
+
}>;
|
|
94
|
+
}>;
|
|
95
|
+
export declare function createMinimalTestServer(): McpServer<Record<never, import("../server/server.js").ToolDef<unknown, unknown, unknown>> & {
|
|
96
|
+
"search-trip": import("../server/server.js").ToolDef<{
|
|
97
|
+
destination: string;
|
|
98
|
+
}, {
|
|
99
|
+
results: {
|
|
100
|
+
id: string;
|
|
101
|
+
}[];
|
|
102
|
+
}, unknown>;
|
|
103
|
+
}>;
|
|
104
|
+
export declare function createInterfaceTestServer(): McpServer<Record<never, import("../server/server.js").ToolDef<unknown, unknown, unknown>> & {
|
|
105
|
+
"interface-view": import("../server/server.js").ToolDef<{
|
|
106
|
+
id: string;
|
|
107
|
+
}, {
|
|
108
|
+
itemName: string;
|
|
109
|
+
quantity: number;
|
|
110
|
+
}, {
|
|
111
|
+
processedBy: string;
|
|
112
|
+
version: number;
|
|
113
|
+
}>;
|
|
114
|
+
}>;
|
|
115
|
+
export declare function createMockExtra(host: string, options?: {
|
|
116
|
+
headers?: Record<string, string | string[]>;
|
|
117
|
+
url?: URL | string;
|
|
118
|
+
}): {
|
|
119
|
+
requestInfo: {
|
|
120
|
+
url?: string | URL | undefined;
|
|
121
|
+
headers: {
|
|
122
|
+
host: string;
|
|
123
|
+
};
|
|
124
|
+
};
|
|
125
|
+
};
|
|
126
|
+
export declare function setTestEnv(env: Record<string, string>): void;
|
|
127
|
+
export declare function resetTestEnv(): void;
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { McpServer as McpServerBase } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
+
import { vi } from "vitest";
|
|
3
|
+
import * as z from "zod";
|
|
4
|
+
import { McpServer } from "../server/server.js";
|
|
5
|
+
export function createMockMcpServer() {
|
|
6
|
+
const server = new McpServer({
|
|
7
|
+
name: "alpic-openai-app",
|
|
8
|
+
version: "0.0.1",
|
|
9
|
+
}, { capabilities: {} });
|
|
10
|
+
const mockRegisterResource = vi.spyOn(server, "registerResource");
|
|
11
|
+
const mockRegisterTool = vi.spyOn(McpServerBase.prototype, "registerTool");
|
|
12
|
+
return {
|
|
13
|
+
server,
|
|
14
|
+
mockRegisterResource,
|
|
15
|
+
mockRegisterTool,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
export function createTestServer() {
|
|
19
|
+
return new McpServer({ name: "test-app", version: "1.0.0" }, {})
|
|
20
|
+
.registerTool({
|
|
21
|
+
name: "search-trip",
|
|
22
|
+
description: "Search for trips",
|
|
23
|
+
inputSchema: {
|
|
24
|
+
destination: z.string(),
|
|
25
|
+
departureDate: z.string().optional(),
|
|
26
|
+
maxPrice: z.number().optional(),
|
|
27
|
+
},
|
|
28
|
+
outputSchema: {
|
|
29
|
+
results: z.array(z.object({
|
|
30
|
+
id: z.string(),
|
|
31
|
+
name: z.string(),
|
|
32
|
+
price: z.number(),
|
|
33
|
+
})),
|
|
34
|
+
totalCount: z.number(),
|
|
35
|
+
},
|
|
36
|
+
view: { component: "search-trip" },
|
|
37
|
+
}, async ({ destination }) => {
|
|
38
|
+
return {
|
|
39
|
+
content: [{ type: "text", text: `Found trips to ${destination}` }],
|
|
40
|
+
structuredContent: {
|
|
41
|
+
results: [{ id: "1", name: "Trip", price: 1000 }],
|
|
42
|
+
totalCount: 1,
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
})
|
|
46
|
+
.registerTool({
|
|
47
|
+
name: "get-trip-details",
|
|
48
|
+
description: "Get trip details",
|
|
49
|
+
inputSchema: {
|
|
50
|
+
tripId: z.string(),
|
|
51
|
+
},
|
|
52
|
+
outputSchema: {
|
|
53
|
+
name: z.string(),
|
|
54
|
+
description: z.string(),
|
|
55
|
+
images: z.array(z.string()),
|
|
56
|
+
},
|
|
57
|
+
view: { component: "get-trip-details" },
|
|
58
|
+
}, async ({ tripId }) => {
|
|
59
|
+
return {
|
|
60
|
+
content: [{ type: "text", text: `Details for ${tripId}` }],
|
|
61
|
+
structuredContent: {
|
|
62
|
+
name: "Trip",
|
|
63
|
+
description: "A great trip",
|
|
64
|
+
images: ["image1.jpg"],
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
})
|
|
68
|
+
.registerTool({
|
|
69
|
+
name: "no-input-view",
|
|
70
|
+
description: "View with no input",
|
|
71
|
+
inputSchema: {},
|
|
72
|
+
outputSchema: {},
|
|
73
|
+
view: { component: "no-input-view" },
|
|
74
|
+
}, async () => {
|
|
75
|
+
return {
|
|
76
|
+
content: [{ type: "text", text: "No input needed" }],
|
|
77
|
+
structuredContent: {},
|
|
78
|
+
};
|
|
79
|
+
})
|
|
80
|
+
.registerTool({
|
|
81
|
+
name: "inferred-output-view",
|
|
82
|
+
description: "View with output inferred from callback",
|
|
83
|
+
inputSchema: {
|
|
84
|
+
query: z.string(),
|
|
85
|
+
},
|
|
86
|
+
view: { component: "inferred-output-view" },
|
|
87
|
+
}, async ({ query }) => {
|
|
88
|
+
return {
|
|
89
|
+
content: [{ type: "text", text: `Query: ${query}` }],
|
|
90
|
+
structuredContent: {
|
|
91
|
+
inferredResults: [{ id: "inferred-1", score: 0.95 }],
|
|
92
|
+
inferredCount: 1,
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
})
|
|
96
|
+
.registerTool({
|
|
97
|
+
name: "calculate-price",
|
|
98
|
+
description: "Calculate trip price",
|
|
99
|
+
inputSchema: {
|
|
100
|
+
tripId: z.string(),
|
|
101
|
+
passengers: z.number(),
|
|
102
|
+
},
|
|
103
|
+
outputSchema: {
|
|
104
|
+
totalPrice: z.number(),
|
|
105
|
+
currency: z.string(),
|
|
106
|
+
},
|
|
107
|
+
}, async ({ tripId, passengers }) => {
|
|
108
|
+
return {
|
|
109
|
+
content: [{ type: "text", text: `Price for ${tripId}` }],
|
|
110
|
+
structuredContent: {
|
|
111
|
+
totalPrice: 1000 * passengers,
|
|
112
|
+
currency: "USD",
|
|
113
|
+
},
|
|
114
|
+
};
|
|
115
|
+
})
|
|
116
|
+
.registerTool({
|
|
117
|
+
name: "inferred-tool",
|
|
118
|
+
description: "Tool with output inferred from callback",
|
|
119
|
+
inputSchema: {
|
|
120
|
+
itemId: z.string(),
|
|
121
|
+
},
|
|
122
|
+
}, async ({ itemId }) => {
|
|
123
|
+
return {
|
|
124
|
+
content: [{ type: "text", text: `Item: ${itemId}` }],
|
|
125
|
+
structuredContent: {
|
|
126
|
+
itemDetails: { name: "Inferred Item", available: true },
|
|
127
|
+
fetchedAt: "2024-01-01",
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
})
|
|
131
|
+
.registerTool({
|
|
132
|
+
name: "view-with-metadata",
|
|
133
|
+
description: "View that returns response metadata",
|
|
134
|
+
inputSchema: {
|
|
135
|
+
resourceId: z.string(),
|
|
136
|
+
},
|
|
137
|
+
view: { component: "view-with-metadata" },
|
|
138
|
+
}, async ({ resourceId }) => {
|
|
139
|
+
return {
|
|
140
|
+
content: [{ type: "text", text: `Resource: ${resourceId}` }],
|
|
141
|
+
structuredContent: {
|
|
142
|
+
data: { id: resourceId, loaded: true },
|
|
143
|
+
},
|
|
144
|
+
_meta: {
|
|
145
|
+
requestId: "req-123",
|
|
146
|
+
timestamp: 1704067200000,
|
|
147
|
+
cached: false,
|
|
148
|
+
},
|
|
149
|
+
};
|
|
150
|
+
})
|
|
151
|
+
.registerTool({
|
|
152
|
+
name: "tool-with-metadata",
|
|
153
|
+
description: "Tool that returns response metadata",
|
|
154
|
+
inputSchema: {
|
|
155
|
+
query: z.string(),
|
|
156
|
+
},
|
|
157
|
+
}, async ({ query }) => {
|
|
158
|
+
return {
|
|
159
|
+
content: [{ type: "text", text: `Query: ${query}` }],
|
|
160
|
+
structuredContent: {
|
|
161
|
+
results: [query],
|
|
162
|
+
},
|
|
163
|
+
_meta: {
|
|
164
|
+
executionTime: 150,
|
|
165
|
+
source: "cache",
|
|
166
|
+
},
|
|
167
|
+
};
|
|
168
|
+
})
|
|
169
|
+
.registerTool({
|
|
170
|
+
name: "view-with-mixed-returns",
|
|
171
|
+
description: "View with mixed return paths (some with _meta, some without)",
|
|
172
|
+
inputSchema: {
|
|
173
|
+
shouldSucceed: z.boolean(),
|
|
174
|
+
},
|
|
175
|
+
view: { component: "view-with-mixed-returns" },
|
|
176
|
+
}, async ({ shouldSucceed }) => {
|
|
177
|
+
if (!shouldSucceed) {
|
|
178
|
+
return {
|
|
179
|
+
content: [{ type: "text", text: "Error occurred" }],
|
|
180
|
+
structuredContent: { error: "Something went wrong" },
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
return {
|
|
184
|
+
content: [{ type: "text", text: "Success" }],
|
|
185
|
+
structuredContent: { data: "result" },
|
|
186
|
+
_meta: {
|
|
187
|
+
processedAt: 1704067200000,
|
|
188
|
+
region: "eu-west-1",
|
|
189
|
+
},
|
|
190
|
+
};
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
export function createMinimalTestServer() {
|
|
194
|
+
return new McpServer({ name: "test-app", version: "1.0.0" }, {}).registerTool({
|
|
195
|
+
name: "search-trip",
|
|
196
|
+
description: "Search for trips",
|
|
197
|
+
inputSchema: {
|
|
198
|
+
destination: z.string(),
|
|
199
|
+
},
|
|
200
|
+
outputSchema: {
|
|
201
|
+
results: z.array(z.object({ id: z.string() })),
|
|
202
|
+
},
|
|
203
|
+
view: { component: "search-trip" },
|
|
204
|
+
}, async ({ destination }) => {
|
|
205
|
+
return {
|
|
206
|
+
content: [{ type: "text", text: `Found trips to ${destination}` }],
|
|
207
|
+
structuredContent: { results: [{ id: "1" }] },
|
|
208
|
+
};
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
export function createInterfaceTestServer() {
|
|
212
|
+
return new McpServer({ name: "interface-test-app", version: "1.0.0" }, {}).registerTool({
|
|
213
|
+
name: "interface-view",
|
|
214
|
+
description: "View with interface-typed output",
|
|
215
|
+
inputSchema: {
|
|
216
|
+
id: z.string(),
|
|
217
|
+
},
|
|
218
|
+
view: { component: "interface-view" },
|
|
219
|
+
}, async ({ id }) => {
|
|
220
|
+
return {
|
|
221
|
+
content: [{ type: "text", text: `Item ${id}` }],
|
|
222
|
+
structuredContent: {
|
|
223
|
+
itemName: "Test Item",
|
|
224
|
+
quantity: 42,
|
|
225
|
+
},
|
|
226
|
+
_meta: {
|
|
227
|
+
processedBy: "test",
|
|
228
|
+
version: 1,
|
|
229
|
+
},
|
|
230
|
+
};
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
export function createMockExtra(host, options) {
|
|
234
|
+
return {
|
|
235
|
+
requestInfo: {
|
|
236
|
+
headers: { host, ...(options?.headers ?? {}) },
|
|
237
|
+
...(options?.url ? { url: options.url } : {}),
|
|
238
|
+
},
|
|
239
|
+
};
|
|
240
|
+
}
|
|
241
|
+
export function setTestEnv(env) {
|
|
242
|
+
Object.assign(process.env, env);
|
|
243
|
+
}
|
|
244
|
+
export function resetTestEnv() {
|
|
245
|
+
delete process.env.NODE_ENV;
|
|
246
|
+
}
|
|
247
|
+
//# sourceMappingURL=utils.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/test/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACrF,OAAO,EAAqB,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC/C,OAAO,KAAK,CAAC,MAAM,KAAK,CAAC;AACzB,OAAO,EAAE,SAAS,EAAiB,MAAM,qBAAqB,CAAC;AAE/D,MAAM,UAAU,mBAAmB;IAKjC,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,EAAE,kBAAkB;QACxB,OAAO,EAAE,OAAO;KACjB,EACD,EAAE,YAAY,EAAE,EAAE,EAAE,CACrB,CAAC;IAEF,MAAM,oBAAoB,GAAG,EAAE,CAAC,KAAK,CAAC,MAAM,EAAE,kBAAkB,CAAC,CAAC;IAClE,MAAM,gBAAgB,GAAG,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,SAAS,EAAE,cAAc,CAAC,CAAC;IAE3E,OAAO;QACL,MAAM;QACN,oBAAoB;QACpB,gBAAgB;KACjB,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO,IAAI,SAAS,CAAC,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,EAAE,EAAE,EAAE,CAAC;SAC7D,YAAY,CACX;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,kBAAkB;QAC/B,WAAW,EAAE;YACX,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,SAAS,EAAE,gBAA4B,EAAE;KAClD,EACD,KAAK,EAAE,EAAE,EAAE,EAAE,EAAgC,EAAE;QAC7C,OAAO;YACL,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE,EAAE,EAAE,CAAC;YAC/C,iBAAiB,EAAE;gBACjB,QAAQ,EAAE,WAAW;gBACrB,QAAQ,EAAE,EAAE;aACb;YACD,KAAK,EAAE;gBACL,WAAW,EAAE,MAAM;gBACnB,OAAO,EAAE,CAAC;aACX;SACF,CAAC;IACJ,CAAC,CACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,eAAe,CAC7B,IAAY,EACZ,OAGC;IAED,OAAO;QACL,WAAW,EAAE;YACX,OAAO,EAAE,EAAE,IAAI,EAAE,GAAG,CAAC,OAAO,EAAE,OAAO,IAAI,EAAE,CAAC,EAAE;YAC9C,GAAG,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC9C;KACF,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,GAA2B;IACpD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AAC9B,CAAC","sourcesContent":["import { McpServer as McpServerBase } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { type MockInstance, vi } from \"vitest\";\nimport * as z from \"zod\";\nimport { McpServer, type ViewName } from \"../server/server.js\";\n\nexport function createMockMcpServer(): {\n server: McpServer;\n mockRegisterResource: MockInstance<McpServer[\"registerResource\"]>;\n mockRegisterTool: MockInstance;\n} {\n const server = new McpServer(\n {\n name: \"alpic-openai-app\",\n version: \"0.0.1\",\n },\n { capabilities: {} },\n );\n\n const mockRegisterResource = vi.spyOn(server, \"registerResource\");\n const mockRegisterTool = vi.spyOn(McpServerBase.prototype, \"registerTool\");\n\n return {\n server,\n mockRegisterResource,\n mockRegisterTool,\n };\n}\n\nexport function createTestServer() {\n return new McpServer({ name: \"test-app\", version: \"1.0.0\" }, {})\n .registerTool(\n {\n name: \"search-trip\",\n description: \"Search for trips\",\n inputSchema: {\n destination: z.string(),\n departureDate: z.string().optional(),\n maxPrice: z.number().optional(),\n },\n outputSchema: {\n results: z.array(\n z.object({\n id: z.string(),\n name: z.string(),\n price: z.number(),\n }),\n ),\n totalCount: z.number(),\n },\n view: { component: \"search-trip\" as ViewName },\n },\n async ({ destination }) => {\n return {\n content: [{ type: \"text\", text: `Found trips to ${destination}` }],\n structuredContent: {\n results: [{ id: \"1\", name: \"Trip\", price: 1000 }],\n totalCount: 1,\n },\n };\n },\n )\n .registerTool(\n {\n name: \"get-trip-details\",\n description: \"Get trip details\",\n inputSchema: {\n tripId: z.string(),\n },\n outputSchema: {\n name: z.string(),\n description: z.string(),\n images: z.array(z.string()),\n },\n view: { component: \"get-trip-details\" as ViewName },\n },\n async ({ tripId }) => {\n return {\n content: [{ type: \"text\", text: `Details for ${tripId}` }],\n structuredContent: {\n name: \"Trip\",\n description: \"A great trip\",\n images: [\"image1.jpg\"],\n },\n };\n },\n )\n .registerTool(\n {\n name: \"no-input-view\",\n description: \"View with no input\",\n inputSchema: {},\n outputSchema: {},\n view: { component: \"no-input-view\" as ViewName },\n },\n async () => {\n return {\n content: [{ type: \"text\", text: \"No input needed\" }],\n structuredContent: {},\n };\n },\n )\n .registerTool(\n {\n name: \"inferred-output-view\",\n description: \"View with output inferred from callback\",\n inputSchema: {\n query: z.string(),\n },\n view: { component: \"inferred-output-view\" as ViewName },\n },\n async ({ query }) => {\n return {\n content: [{ type: \"text\", text: `Query: ${query}` }],\n structuredContent: {\n inferredResults: [{ id: \"inferred-1\", score: 0.95 }],\n inferredCount: 1,\n },\n };\n },\n )\n .registerTool(\n {\n name: \"calculate-price\",\n description: \"Calculate trip price\",\n inputSchema: {\n tripId: z.string(),\n passengers: z.number(),\n },\n outputSchema: {\n totalPrice: z.number(),\n currency: z.string(),\n },\n },\n async ({ tripId, passengers }) => {\n return {\n content: [{ type: \"text\", text: `Price for ${tripId}` }],\n structuredContent: {\n totalPrice: 1000 * passengers,\n currency: \"USD\",\n },\n };\n },\n )\n .registerTool(\n {\n name: \"inferred-tool\",\n description: \"Tool with output inferred from callback\",\n inputSchema: {\n itemId: z.string(),\n },\n },\n async ({ itemId }) => {\n return {\n content: [{ type: \"text\", text: `Item: ${itemId}` }],\n structuredContent: {\n itemDetails: { name: \"Inferred Item\", available: true },\n fetchedAt: \"2024-01-01\",\n },\n };\n },\n )\n .registerTool(\n {\n name: \"view-with-metadata\",\n description: \"View that returns response metadata\",\n inputSchema: {\n resourceId: z.string(),\n },\n view: { component: \"view-with-metadata\" as ViewName },\n },\n async ({ resourceId }) => {\n return {\n content: [{ type: \"text\", text: `Resource: ${resourceId}` }],\n structuredContent: {\n data: { id: resourceId, loaded: true },\n },\n _meta: {\n requestId: \"req-123\",\n timestamp: 1704067200000,\n cached: false,\n },\n };\n },\n )\n .registerTool(\n {\n name: \"tool-with-metadata\",\n description: \"Tool that returns response metadata\",\n inputSchema: {\n query: z.string(),\n },\n },\n async ({ query }) => {\n return {\n content: [{ type: \"text\", text: `Query: ${query}` }],\n structuredContent: {\n results: [query],\n },\n _meta: {\n executionTime: 150,\n source: \"cache\",\n },\n };\n },\n )\n .registerTool(\n {\n name: \"view-with-mixed-returns\",\n description:\n \"View with mixed return paths (some with _meta, some without)\",\n inputSchema: {\n shouldSucceed: z.boolean(),\n },\n view: { component: \"view-with-mixed-returns\" as ViewName },\n },\n async ({ shouldSucceed }) => {\n if (!shouldSucceed) {\n return {\n content: [{ type: \"text\", text: \"Error occurred\" }],\n structuredContent: { error: \"Something went wrong\" },\n };\n }\n return {\n content: [{ type: \"text\", text: \"Success\" }],\n structuredContent: { data: \"result\" },\n _meta: {\n processedAt: 1704067200000,\n region: \"eu-west-1\",\n },\n };\n },\n );\n}\n\nexport function createMinimalTestServer() {\n return new McpServer({ name: \"test-app\", version: \"1.0.0\" }, {}).registerTool(\n {\n name: \"search-trip\",\n description: \"Search for trips\",\n inputSchema: {\n destination: z.string(),\n },\n outputSchema: {\n results: z.array(z.object({ id: z.string() })),\n },\n view: { component: \"search-trip\" as ViewName },\n },\n async ({ destination }) => {\n return {\n content: [{ type: \"text\", text: `Found trips to ${destination}` }],\n structuredContent: { results: [{ id: \"1\" }] },\n };\n },\n );\n}\n\ninterface InterfaceOutput {\n itemName: string;\n quantity: number;\n}\n\ninterface InterfaceMeta {\n processedBy: string;\n version: number;\n}\n\ninterface InterfaceReturnType {\n content: [{ type: \"text\"; text: string }];\n structuredContent: InterfaceOutput;\n _meta: InterfaceMeta;\n}\n\nexport function createInterfaceTestServer() {\n return new McpServer(\n { name: \"interface-test-app\", version: \"1.0.0\" },\n {},\n ).registerTool(\n {\n name: \"interface-view\" as const,\n description: \"View with interface-typed output\",\n inputSchema: {\n id: z.string(),\n },\n view: { component: \"interface-view\" as ViewName },\n },\n async ({ id }): Promise<InterfaceReturnType> => {\n return {\n content: [{ type: \"text\", text: `Item ${id}` }],\n structuredContent: {\n itemName: \"Test Item\",\n quantity: 42,\n },\n _meta: {\n processedBy: \"test\",\n version: 1,\n },\n };\n },\n );\n}\n\nexport function createMockExtra(\n host: string,\n options?: {\n headers?: Record<string, string | string[]>;\n url?: URL | string;\n },\n) {\n return {\n requestInfo: {\n headers: { host, ...(options?.headers ?? {}) },\n ...(options?.url ? { url: options.url } : {}),\n },\n };\n}\n\nexport function setTestEnv(env: Record<string, string>) {\n Object.assign(process.env, env);\n}\n\nexport function resetTestEnv() {\n delete process.env.NODE_ENV;\n}\n"]}
|