skybridge 0.0.0-dev.fc2b7e8 → 0.0.0-dev.fc2b815
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +152 -0
- 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/create.d.ts +9 -0
- package/dist/commands/create.js +30 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dev.d.ts +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 +11 -0
- package/dist/server/asset-base-url-transform-plugin.js +48 -0
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -0
- package/dist/server/asset-base-url-transform-plugin.test.js +134 -0
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -0
- package/dist/server/auth.d.ts +20 -0
- package/dist/server/auth.js +28 -0
- package/dist/server/auth.js.map +1 -0
- package/dist/server/content-helpers.d.ts +67 -0
- package/dist/server/content-helpers.js +79 -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/file-ref.d.ts +28 -0
- package/dist/server/file-ref.js +27 -0
- package/dist/server/file-ref.js.map +1 -0
- package/dist/server/index.d.ts +8 -0
- package/dist/server/index.js +6 -0
- package/dist/server/index.js.map +1 -0
- package/dist/{src/server → server}/inferUtilityTypes.d.ts +6 -6
- 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 +137 -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 +398 -0
- package/dist/server/server.js +561 -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/{src/test → test}/utils.d.ts +23 -20
- package/dist/{src/test → test}/utils.js +60 -35
- package/dist/test/utils.js.map +1 -0
- package/dist/test/view.test.js +568 -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 +28 -0
- package/dist/web/bridges/apps-sdk/adaptor.js +113 -0
- package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -0
- package/dist/web/bridges/apps-sdk/bridge.d.ts +11 -0
- package/dist/web/bridges/apps-sdk/bridge.js +47 -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 +133 -0
- package/dist/{src/web → web/bridges/apps-sdk}/types.js +0 -1
- package/dist/web/bridges/apps-sdk/types.js.map +1 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +13 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +18 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -0
- package/dist/web/bridges/get-adaptor.d.ts +9 -0
- package/dist/web/bridges/get-adaptor.js +15 -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 +52 -0
- package/dist/web/bridges/mcp-app/adaptor.js +280 -0
- package/dist/web/bridges/mcp-app/adaptor.js.map +1 -0
- package/dist/web/bridges/mcp-app/bridge.d.ts +27 -0
- package/dist/web/bridges/mcp-app/bridge.js +103 -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 +19 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +19 -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 +171 -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 +7 -0
- package/dist/web/bridges/use-host-context.js +13 -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 +29 -0
- package/dist/web/create-store.js +64 -0
- package/dist/web/create-store.js.map +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 +47 -0
- package/dist/{src/web → web}/data-llm.js +39 -7
- package/dist/web/data-llm.js.map +1 -0
- package/dist/web/data-llm.test.js +142 -0
- package/dist/web/data-llm.test.js.map +1 -0
- package/dist/{src/web → web}/generate-helpers.d.ts +24 -19
- package/dist/{src/web → web}/generate-helpers.js +22 -18
- package/dist/web/generate-helpers.js.map +1 -0
- package/dist/{src/web → web}/generate-helpers.test-d.js +56 -27
- package/dist/web/generate-helpers.test-d.js.map +1 -0
- package/dist/web/generate-helpers.test.js.map +1 -0
- package/dist/{src/web → web}/helpers/state.d.ts +2 -2
- package/dist/web/helpers/state.js +45 -0
- package/dist/web/helpers/state.js.map +1 -0
- package/dist/{src/web → web}/helpers/state.test.js +9 -9
- package/dist/web/helpers/state.test.js.map +1 -0
- package/dist/web/hooks/index.d.ts +14 -0
- package/dist/web/hooks/index.js +15 -0
- package/dist/web/hooks/index.js.map +1 -0
- package/dist/web/hooks/test/utils.d.ts +20 -0
- package/dist/web/hooks/test/utils.js +75 -0
- package/dist/web/hooks/test/utils.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-call-tool.d.ts +47 -1
- package/dist/web/hooks/use-call-tool.js +96 -0
- package/dist/web/hooks/use-call-tool.js.map +1 -0
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-call-tool.test.js +50 -4
- package/dist/web/hooks/use-call-tool.test.js.map +1 -0
- package/dist/web/hooks/use-display-mode.d.ts +24 -0
- package/dist/web/hooks/use-display-mode.js +29 -0
- package/dist/web/hooks/use-display-mode.js.map +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/{src/web → web}/hooks/use-display-mode.test.js +1 -0
- package/dist/web/hooks/use-display-mode.test.js.map +1 -0
- package/dist/web/hooks/use-download.d.ts +5 -0
- package/dist/web/hooks/use-download.js +8 -0
- package/dist/web/hooks/use-download.js.map +1 -0
- package/dist/web/hooks/use-download.test.d.ts +1 -0
- package/dist/web/hooks/use-download.test.js +95 -0
- package/dist/web/hooks/use-download.test.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +39 -0
- package/dist/web/hooks/use-files.js +42 -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 +24 -0
- package/dist/web/hooks/use-layout.js +25 -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 +20 -0
- package/dist/web/hooks/use-open-external.js +24 -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-close.d.ts +16 -0
- package/dist/web/hooks/use-request-close.js +21 -0
- package/dist/web/hooks/use-request-close.js.map +1 -0
- package/dist/web/hooks/use-request-close.test.d.ts +1 -0
- package/dist/web/hooks/use-request-close.test.js +52 -0
- package/dist/web/hooks/use-request-close.test.js.map +1 -0
- package/dist/web/hooks/use-request-modal.d.ts +24 -0
- package/dist/web/hooks/use-request-modal.js +31 -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-request-size.d.ts +20 -0
- package/dist/web/hooks/use-request-size.js +24 -0
- package/dist/web/hooks/use-request-size.js.map +1 -0
- package/dist/web/hooks/use-request-size.test.d.ts +1 -0
- package/dist/web/hooks/use-request-size.test.js +65 -0
- package/dist/web/hooks/use-request-size.test.js.map +1 -0
- package/dist/web/hooks/use-send-follow-up-message.d.ts +19 -0
- package/dist/web/hooks/use-send-follow-up-message.js +25 -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 +18 -0
- package/dist/web/hooks/use-set-open-in-app-url.js +25 -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 +69 -0
- package/dist/web/hooks/use-tool-info.js +52 -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/{src/web → web}/hooks/use-tool-info.test-d.js +40 -4
- 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 +20 -0
- package/dist/web/hooks/use-user.js +37 -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 +25 -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/{src/web → web}/index.d.ts +2 -2
- package/dist/{src/web → web}/index.js +2 -2
- package/dist/web/index.js.map +1 -0
- package/dist/web/mount-view.d.ts +20 -0
- package/dist/web/mount-view.js +46 -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.map +1 -0
- package/dist/web/plugin/plugin.d.ts +33 -0
- package/dist/web/plugin/plugin.js +189 -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/{src/web → web}/plugin/transform-data-llm.js +7 -4
- 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.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/{src/web → web}/proxy.js +5 -1
- package/dist/web/proxy.js.map +1 -0
- package/dist/web/types.d.ts +20 -0
- package/dist/web/types.js +2 -0
- package/dist/web/types.js.map +1 -0
- package/package.json +78 -33
- package/tsconfig.base.json +33 -0
- package/dist/src/server/devtoolsStaticServer.d.ts +0 -15
- package/dist/src/server/devtoolsStaticServer.js +0 -43
- package/dist/src/server/devtoolsStaticServer.js.map +0 -1
- package/dist/src/server/index.d.ts +0 -5
- package/dist/src/server/index.js +0 -4
- package/dist/src/server/index.js.map +0 -1
- package/dist/src/server/inferUtilityTypes.js.map +0 -1
- package/dist/src/server/server.d.ts +0 -62
- package/dist/src/server/server.js +0 -62
- package/dist/src/server/server.js.map +0 -1
- package/dist/src/server/templateHelper.js +0 -30
- 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/utils.js.map +0 -1
- package/dist/src/test/widget.test.js +0 -95
- package/dist/src/test/widget.test.js.map +0 -1
- package/dist/src/web/create-store.d.ts +0 -3
- package/dist/src/web/create-store.js +0 -25
- package/dist/src/web/create-store.js.map +0 -1
- package/dist/src/web/create-store.test.js +0 -70
- package/dist/src/web/create-store.test.js.map +0 -1
- package/dist/src/web/data-llm.d.ts +0 -14
- package/dist/src/web/data-llm.js.map +0 -1
- package/dist/src/web/data-llm.test.js +0 -76
- package/dist/src/web/data-llm.test.js.map +0 -1
- package/dist/src/web/generate-helpers.js.map +0 -1
- package/dist/src/web/generate-helpers.test-d.js.map +0 -1
- package/dist/src/web/generate-helpers.test.js.map +0 -1
- package/dist/src/web/helpers/state.js +0 -40
- package/dist/src/web/helpers/state.js.map +0 -1
- package/dist/src/web/helpers/state.test.js.map +0 -1
- package/dist/src/web/hooks/index.d.ts +0 -12
- package/dist/src/web/hooks/index.js +0 -13
- package/dist/src/web/hooks/index.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.js +0 -60
- package/dist/src/web/hooks/use-call-tool.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.test-d.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-files.d.ts +0 -10
- package/dist/src/web/hooks/use-files.js +0 -7
- package/dist/src/web/hooks/use-files.js.map +0 -1
- package/dist/src/web/hooks/use-files.test.js +0 -29
- package/dist/src/web/hooks/use-files.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 -25
- package/dist/src/web/hooks/use-openai-global.js.map +0 -1
- package/dist/src/web/hooks/use-request-modal.d.ts +0 -6
- 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 -25
- package/dist/src/web/hooks/use-tool-info.js +0 -20
- package/dist/src/web/hooks/use-tool-info.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.test-d.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.test.js +0 -59
- package/dist/src/web/hooks/use-tool-info.test.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 -32
- package/dist/src/web/hooks/use-widget-state.js.map +0 -1
- package/dist/src/web/hooks/use-widget-state.test.js +0 -60
- package/dist/src/web/hooks/use-widget-state.test.js.map +0 -1
- 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 -19
- package/dist/src/web/mount-widget.js.map +0 -1
- package/dist/src/web/plugin/data-llm.test.js.map +0 -1
- package/dist/src/web/plugin/plugin.d.ts +0 -2
- package/dist/src/web/plugin/plugin.js +0 -33
- package/dist/src/web/plugin/plugin.js.map +0 -1
- package/dist/src/web/plugin/transform-data-llm.js.map +0 -1
- package/dist/src/web/plugin/transform-data-llm.test.js.map +0 -1
- package/dist/src/web/proxy.js.map +0 -1
- package/dist/src/web/types.d.ts +0 -133
- package/dist/src/web/types.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -8
- package/dist/vitest.config.js.map +0 -1
- /package/dist/{src/test/widget.test.d.ts → cli/tunnel-control-server.test.d.ts} +0 -0
- /package/dist/{src/web/create-store.test.d.ts → cli/tunnel-handler.test.d.ts} +0 -0
- /package/dist/{src/web/data-llm.test.d.ts → cli/tunnel.test.d.ts} +0 -0
- /package/dist/{src/web/generate-helpers.test-d.d.ts → server/asset-base-url-transform-plugin.test.d.ts} +0 -0
- /package/dist/{src/web/generate-helpers.test.d.ts → server/content-helpers.test.d.ts} +0 -0
- /package/dist/{src/web/helpers/state.test.d.ts → server/express.test.d.ts} +0 -0
- /package/dist/{src/server → server}/inferUtilityTypes.js +0 -0
- /package/dist/{src/web/hooks/use-call-tool.test-d.d.ts → server/middleware.test-d.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-call-tool.test.d.ts → server/middleware.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-display-mode.test.d.ts → server/tunnel-proxy-router.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-files.test.d.ts → test/view.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-locale.test.d.ts → web/bridges/mcp-app/use-mcp-app-context.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-open-external.test.d.ts → web/create-store.test.d.ts} +0 -0
- /package/dist/{src/web/plugin → web}/data-llm.test.d.ts +0 -0
- /package/dist/{src/web/hooks/use-request-modal.test.d.ts → web/generate-helpers.test-d.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-theme.test.d.ts → web/generate-helpers.test.d.ts} +0 -0
- /package/dist/{src/web → web}/generate-helpers.test.js +0 -0
- /package/dist/{src/web/hooks/use-tool-info.test-d.d.ts → web/helpers/state.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-tool-info.test.d.ts → web/hooks/use-call-tool.test-d.d.ts} +0 -0
- /package/dist/{src/web → web}/hooks/use-call-tool.test-d.js +0 -0
- /package/dist/{src/web/hooks/use-user-agent.test.d.ts → web/hooks/use-call-tool.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-widget-state.test.d.ts → web/hooks/use-display-mode.test-d.d.ts} +0 -0
- /package/dist/{src/web/plugin/transform-data-llm.test.d.ts → web/hooks/use-display-mode.test.d.ts} +0 -0
- /package/dist/{src/web → web}/plugin/data-llm.test.js +0 -0
- /package/dist/{src/web → web}/plugin/transform-data-llm.d.ts +0 -0
- /package/dist/{src/web → web}/plugin/transform-data-llm.test.js +0 -0
- /package/dist/{src/web → web}/proxy.d.ts +0 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"scan-views.test.js","sourceRoot":"","sources":["../../../src/web/plugin/scan-views.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,WAAW,EACX,YAAY,EACZ,MAAM,EACN,QAAQ,EACR,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AACrE,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,aAAa,EACb,aAAa,GACd,MAAM,iBAAiB,CAAC;AAEzB,MAAM,cAAc,GAAG,8CAA8C,CAAC;AAEtE,QAAQ,CAAC,mBAAmB,EAAE,GAAG,EAAE;IACjC,IAAI,IAAY,CAAC;IACjB,IAAI,QAAgB,CAAC;IAErB,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,GAAG,WAAW,CAAC,IAAI,CAAC,MAAM,EAAE,EAAE,iBA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,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,mCAAmC,CAAC,CAAC;QAC/D,MAAM,CAAC,OAAO,CAAC,CAAC,SAAS,CAAC,gBAAgB,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import {\n mkdirSync,\n mkdtempSync,\n readFileSync,\n rmSync,\n statSync,\n writeFileSync,\n} from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { afterEach, beforeEach, describe, expect, it } from \"vitest\";\nimport {\n discoverViewsSync,\n scanAndWriteViewsDts,\n scanViewsSync,\n writeViewsDts,\n} from \"./scan-views.js\";\n\nconst DEFAULT_EXPORT = \"export default function V() { return null; }\";\n\ndescribe(\"discoverViewsSync\", () => {\n let root: string;\n let viewsDir: string;\n\n beforeEach(() => {\n root = mkdtempSync(join(tmpdir(), \"skybridge-scan-\"));\n viewsDir = join(root, \"views\");\n mkdirSync(viewsDir, { recursive: true });\n });\n\n afterEach(() => {\n rmSync(root, { recursive: true, force: true });\n });\n\n it(\"picks up flat and dir-index views\", () => {\n writeFileSync(join(viewsDir, \"a.tsx\"), DEFAULT_EXPORT);\n mkdirSync(join(viewsDir, \"my-view\"));\n writeFileSync(join(viewsDir, \"my-view/index.tsx\"), DEFAULT_EXPORT);\n\n expect(\n discoverViewsSync(viewsDir)\n .map((v) => v.name)\n .sort(),\n ).toEqual([\"a\", \"my-view\"]);\n });\n\n it(\"throws on duplicate view names (flat + dir-index collision)\", () => {\n writeFileSync(join(viewsDir, \"dup.tsx\"), DEFAULT_EXPORT);\n mkdirSync(join(viewsDir, \"dup\"));\n writeFileSync(join(viewsDir, \"dup/index.tsx\"), DEFAULT_EXPORT);\n\n expect(() => discoverViewsSync(viewsDir)).toThrow(\n /duplicate view name \"dup\"/,\n );\n });\n});\n\ndescribe(\"scanViewsSync\", () => {\n let root: string;\n let viewsDir: string;\n\n beforeEach(() => {\n root = mkdtempSync(join(tmpdir(), \"skybridge-scan-views-\"));\n viewsDir = join(root, \"views\");\n mkdirSync(viewsDir, { recursive: true });\n });\n\n afterEach(() => {\n rmSync(root, { recursive: true, force: true });\n });\n\n it(\"returns valid and invalid views from a flat layout\", () => {\n writeFileSync(join(viewsDir, \"ok.tsx\"), DEFAULT_EXPORT);\n writeFileSync(\n join(viewsDir, \"broken.tsx\"),\n \"export const Foo = () => null;\",\n );\n\n const { valid, invalid } = scanViewsSync(viewsDir);\n\n expect(valid.map((v) => v.name).sort()).toEqual([\"ok\"]);\n expect(invalid).toEqual([{ filePath: join(viewsDir, \"broken.tsx\") }]);\n });\n\n it(\"flags an index file in a view dir that lacks a default export\", () => {\n mkdirSync(join(viewsDir, \"broken\"));\n writeFileSync(\n join(viewsDir, \"broken/index.tsx\"),\n \"export const Foo = () => null;\",\n );\n\n const { valid, invalid } = scanViewsSync(viewsDir);\n\n expect(valid).toEqual([]);\n expect(invalid).toEqual([{ filePath: join(viewsDir, \"broken/index.tsx\") }]);\n });\n\n it(\"ignores top-level index.tsx (treated as a barrel, not a view)\", () => {\n writeFileSync(\n join(viewsDir, \"index.tsx\"),\n \"export const Foo = () => null;\",\n );\n\n const { valid, invalid } = scanViewsSync(viewsDir);\n\n expect(valid).toEqual([]);\n expect(invalid).toEqual([]);\n });\n});\n\ndescribe(\"writeViewsDts\", () => {\n let root: string;\n\n beforeEach(() => {\n root = mkdtempSync(join(tmpdir(), \"skybridge-dts-\"));\n });\n\n afterEach(() => {\n rmSync(root, { recursive: true, force: true });\n });\n\n it(\"is a no-op when content is unchanged\", () => {\n const views = [{ name: \"a\", filePath: \"/a.tsx\" }];\n writeViewsDts(root, views);\n\n const dtsPath = join(root, \".skybridge\", \"views.d.ts\");\n const firstMtime = statSync(dtsPath).mtimeMs;\n\n writeViewsDts(root, views);\n expect(statSync(dtsPath).mtimeMs).toBe(firstMtime);\n });\n});\n\ndescribe(\"scanAndWriteViewsDts\", () => {\n let root: string;\n\n beforeEach(() => {\n root = mkdtempSync(join(tmpdir(), \"skybridge-scan-dts-\"));\n mkdirSync(join(root, \"src/views\"), { recursive: true });\n writeFileSync(join(root, \"src/views/hello.tsx\"), DEFAULT_EXPORT);\n });\n\n afterEach(() => {\n rmSync(root, { recursive: true, force: true });\n });\n\n it(\"writes a views.d.ts that augments skybridge/server with discovered view names\", () => {\n scanAndWriteViewsDts(root);\n\n const content = readFileSync(join(root, \".skybridge/views.d.ts\"), \"utf-8\");\n expect(content).toContain('declare module \"skybridge/server\"');\n expect(content).toContain('\"hello\": true;');\n });\n});\n"]}
|
|
@@ -8,10 +8,12 @@ function createBabelPlugin(t) {
|
|
|
8
8
|
state.hasDataLLMImport = false;
|
|
9
9
|
state.needsDataLLMImport = false;
|
|
10
10
|
for (const node of path.node.body) {
|
|
11
|
-
if (!t.isImportDeclaration(node))
|
|
11
|
+
if (!t.isImportDeclaration(node)) {
|
|
12
12
|
continue;
|
|
13
|
-
|
|
13
|
+
}
|
|
14
|
+
if (node.source.value !== LLM_IMPORT_SOURCE) {
|
|
14
15
|
continue;
|
|
16
|
+
}
|
|
15
17
|
const hasSpecifier = node.specifiers.some((s) => t.isImportSpecifier(s) &&
|
|
16
18
|
t.isIdentifier(s.imported, { name: "DataLLM" }));
|
|
17
19
|
if (hasSpecifier) {
|
|
@@ -34,8 +36,9 @@ function createBabelPlugin(t) {
|
|
|
34
36
|
const attributes = opening.attributes;
|
|
35
37
|
const llmAttributeIndex = attributes.findIndex((attribute) => t.isJSXAttribute(attribute) &&
|
|
36
38
|
t.isJSXIdentifier(attribute.name, { name: "data-llm" }));
|
|
37
|
-
if (llmAttributeIndex === -1)
|
|
39
|
+
if (llmAttributeIndex === -1) {
|
|
38
40
|
return;
|
|
41
|
+
}
|
|
39
42
|
const llmAttribute = attributes[llmAttributeIndex];
|
|
40
43
|
let contentExpression;
|
|
41
44
|
if (t.isStringLiteral(llmAttribute.value)) {
|
|
@@ -82,7 +85,7 @@ export const transform = async (code, id) => {
|
|
|
82
85
|
sourceFileName: id,
|
|
83
86
|
};
|
|
84
87
|
const result = transformSync(code, babelOptions);
|
|
85
|
-
if (!result
|
|
88
|
+
if (!result?.code) {
|
|
86
89
|
return null;
|
|
87
90
|
}
|
|
88
91
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-data-llm.js","sourceRoot":"","sources":["../../../src/web/plugin/transform-data-llm.ts"],"names":[],"mappings":"AAEA,MAAM,iBAAiB,GAAG,eAAe,CAAC;AAO1C,SAAS,iBAAiB,CAAC,CAAe;IACxC,OAAO;QACL,IAAI,EAAE,gBAAgB;QAEtB,OAAO,EAAE;YACP,OAAO,EAAE;gBACP,KAAK,CAAC,IAAI,EAAE,KAAK;oBACf,KAAK,CAAC,gBAAgB,GAAG,KAAK,CAAC;oBAC/B,KAAK,CAAC,kBAAkB,GAAG,KAAK,CAAC;oBAEjC,KAAK,MAAM,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC;wBAClC,IAAI,CAAC,CAAC,CAAC,mBAAmB,CAAC,IAAI,CAAC,EAAE,CAAC;4BACjC,SAAS;wBACX,CAAC;wBACD,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,KAAK,iBAAiB,EAAE,CAAC;4BAC5C,SAAS;wBACX,CAAC;wBAED,MAAM,YAAY,GAAG,IAAI,CAAC,UAAU,CAAC,IAAI,CACvC,CAAC,CAAC,EAAE,EAAE,CACJ,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC;4BACtB,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,IAAI,EAAE,SAAS,EAAE,CAAC,CAClD,CAAC;wBAEF,IAAI,YAAY,EAAE,CAAC;4BACjB,KAAK,CAAC,gBAAgB,GAAG,IAAI,CAAC;4BAC9B,MAAM;wBACR,CAAC;oBACH,CAAC;gBACH,CAAC;gBAED,IAAI,CAAC,IAAI,EAAE,KAAK;oBACd,IAAI,KAAK,CAAC,kBAAkB,IAAI,CAAC,K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AAC,EAAE,CAAC,EAAE,CAAC;QAC7B,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,EAAE,CAAC,QAAQ,CAAC,cAAc,CAAC,EAAE,CAAC;QAChC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,yEAAyE;IACzE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE,aAAa,EAAE,GAAG,MAAM,MAAM,CAAC,aAAa,CAAC,CAAC;IAEhE,MAAM,YAAY,GAAqB;QACrC,OAAO,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC;QAC/B,UAAU,EAAE;YACV,OAAO,EAAE,CAAC,KAAK,EAAE,YAAY,CAAC;SAC/B;QACD,QAAQ,EAAE,EAAE;QACZ,cAAc,EAAE,EAAE;KACnB,CAAC;IAEF,MAAM,MAAM,GAAG,aAAa,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC;IAEjD,IAAI,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC;QAClB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,OAAO;QACL,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,EAAE,MAAM,CAAC,GAAG,IAAI,IAAI;KACxB,CAAC;AACJ,CAAC,CAAC","sourcesContent":["import type { PluginObj, TransformOptions, types } from \"@babel/core\";\n\nconst LLM_IMPORT_SOURCE = \"skybridge/web\";\n\ninterface State {\n hasDataLLMImport?: boolean;\n needsDataLLMImport?: boolean;\n}\n\nfunction createBabelPlugin(t: typeof types): PluginObj<State> {\n return {\n name: \"data-llm-babel\",\n\n visitor: {\n Program: {\n enter(path, state) {\n state.hasDataLLMImport = false;\n state.needsDataLLMImport = false;\n\n for (const node of path.node.body) {\n if (!t.isImportDeclaration(node)) {\n continue;\n }\n if (node.source.value !== LLM_IMPORT_SOURCE) {\n continue;\n }\n\n const hasSpecifier = node.specifiers.some(\n (s) =>\n t.isImportSpecifier(s) &&\n t.isIdentifier(s.imported, { name: \"DataLLM\" }),\n );\n\n if (hasSpecifier) {\n state.hasDataLLMImport = true;\n break;\n }\n }\n },\n\n exit(path, state) {\n if (state.needsDataLLMImport && !state.hasDataLLMImport) {\n const importDecl = t.importDeclaration(\n [\n t.importSpecifier(\n t.identifier(\"DataLLM\"),\n t.identifier(\"DataLLM\"),\n ),\n ],\n t.stringLiteral(LLM_IMPORT_SOURCE),\n );\n\n path.node.body.unshift(importDecl);\n }\n },\n },\n\n JSXElement(path, state) {\n const opening = path.node.openingElement;\n const attributes = opening.attributes;\n\n const llmAttributeIndex = attributes.findIndex(\n (attribute) =>\n t.isJSXAttribute(attribute) &&\n t.isJSXIdentifier(attribute.name, { name: \"data-llm\" }),\n );\n\n if (llmAttributeIndex === -1) {\n return;\n }\n\n const llmAttribute = attributes[\n llmAttributeIndex\n ] as types.JSXAttribute;\n\n let contentExpression: types.Expression;\n\n if (t.isStringLiteral(llmAttribute.value)) {\n contentExpression = llmAttribute.value;\n } else if (t.isJSXExpressionContainer(llmAttribute.value)) {\n contentExpression = llmAttribute.value.expression as types.Expression;\n } else {\n return;\n }\n\n const contentAttr = t.jsxAttribute(\n t.jsxIdentifier(\"content\"),\n t.isStringLiteral(contentExpression)\n ? contentExpression\n : t.jsxExpressionContainer(contentExpression),\n );\n\n const filteredAttributes = attributes.filter(\n (_, index) => index !== llmAttributeIndex,\n );\n const newOpening = t.jsxOpeningElement(\n opening.name,\n filteredAttributes,\n opening.selfClosing,\n );\n\n const elementWithoutLlm = t.jsxElement(\n newOpening,\n path.node.closingElement,\n path.node.children,\n path.node.selfClosing,\n );\n\n const llmOpening = t.jsxOpeningElement(t.jsxIdentifier(\"DataLLM\"), [\n contentAttr,\n ]);\n const llmClosing = t.jsxClosingElement(t.jsxIdentifier(\"DataLLM\"));\n\n const wrapped = t.jsxElement(\n llmOpening,\n llmClosing,\n [elementWithoutLlm],\n false,\n );\n\n state.needsDataLLMImport = true;\n path.replaceWith(wrapped);\n },\n },\n };\n}\n\nexport const transform = async (code: string, id: string) => {\n if (!/\\.(jsx|tsx)$/.test(id)) {\n return null;\n }\n\n if (id.includes(\"node_modules\")) {\n return null;\n }\n\n // Dynamic import to ensure @babel/core is only loaded in Node.js context\n const { types: t, transformSync } = await import(\"@babel/core\");\n\n const babelOptions: TransformOptions = {\n plugins: [createBabelPlugin(t)],\n parserOpts: {\n plugins: [\"jsx\", \"typescript\"],\n },\n filename: id,\n sourceFileName: id,\n };\n\n const result = transformSync(code, babelOptions);\n\n if (!result?.code) {\n return null;\n }\n\n return {\n code: result.code,\n map: result.map || null,\n };\n};\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transform-data-llm.test.js","sourceRoot":"","sources":["../../../src/web/plugin/transform-data-llm.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAEpD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,IAAI,GAAG;;;;KAIZ,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC;QAC9B,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;QAC1C,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,4BAA4B,CAAC,CAAC;QAC7D,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iEAAiE,EAAE,KAAK,IAAI,EAAE;Q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CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,2BAA2B,CAAC,CAAC;QAC7D,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,kCAAkC,CAAC,CAAC;QACpE,MAAM,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,yCAAyC,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,6DAA6D,EAAE,KAAK,IAAI,EAAE;QAC3E,MAAM,IAAI,GAAG;;;;;;;;;;;;;KAaZ,CAAC;QAEF,MAAM,MAAM,GAAG,MAAM,SAAS,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAEjD,MAAM,CAAC,MAAM,CAAC,CAAC,eAAe,EAAE,CAAC;IACnC,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { transform } from \"./transform-data-llm.js\";\n\ndescribe(\"data-llm plugin\", () => {\n it(\"should transform JSX element with data-llm string attribute\", async () => {\n const code = `\n function Component() {\n return <div data-llm=\"Test description\">Content</div>;\n }\n `;\n\n const result = await transform(code, \"test.tsx\");\n\n expect(result).not.toBeNull();\n expect(result?.code).toContain(\"DataLLM\");\n expect(result?.code).toContain('content=\"Test description\"');\n expect(result?.code).not.toContain(\"data-llm\");\n });\n\n it(\"should transform JSX element with data-llm expression attribute\", async () => {\n const code = `\n function Component() {\n const desc = \"Dynamic description\";\n return <div data-llm={desc}>Content</div>;\n }\n `;\n\n const result = await transform(code, \"test.tsx\");\n\n expect(result).not.toBeNull();\n expect(result?.code).toContain(\"DataLLM\");\n expect(result?.code).toContain(\"content={desc}\");\n expect(result?.code).not.toContain(\"data-llm\");\n });\n\n it(\"should add import for DataLLM when not present\", async () => {\n const code = `\n function Component() {\n return <div data-llm=\"Test\">Content</div>;\n }\n `;\n\n const result = await transform(code, \"test.tsx\");\n\n expect(result).not.toBeNull();\n expect(result?.code).toContain('import { DataLLM } from \"skybridge/web\"');\n });\n\n it(\"should handle DataLLM imports correctly\", async () => {\n // No duplicate import\n const codeWithImport = `\n import { DataLLM } from \"skybridge/web\";\n function Component() {\n return <div data-llm=\"Test\">Content</div>;\n }\n `;\n const result1 = await transform(codeWithImport, \"test.tsx\");\n expect(\n result1?.code.match(/import.*DataLLM.*from.*skybridge\\/web/g),\n ).toHaveLength(1);\n\n // Preserve other imports and add missing DataLLM\n const codeWithOthers = `\n import React from \"react\";\n import { useState } from \"react\";\n function Component() {\n return <div data-llm=\"Test\">Content</div>;\n }\n `;\n const result2 = await transform(codeWithOthers, \"test.tsx\");\n expect(result2?.code).toContain('import React from \"react\"');\n expect(result2?.code).toContain('import { useState } from \"react\"');\n expect(result2?.code).toContain('import { DataLLM } from \"skybridge/web\"');\n });\n\n it(\"should handle complex JSX with multiple data-llm attributes\", async () => {\n const code = `\n function Component() {\n return (\n <div>\n <section data-llm=\"Section 1\">\n <p>Content 1</p>\n </section>\n <section data-llm=\"Section 2\">\n <p>Content 2</p>\n </section>\n </div>\n );\n }\n `;\n\n const result = await transform(code, \"test.tsx\");\n\n expect(result).toMatchSnapshot();\n });\n});\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function hasDefaultExport(code: string, _filePath?: string): boolean;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
function stripComments(code) {
|
|
2
|
+
return code.replace(/\/\/.*$/gm, "").replace(/\/\*[\s\S]*?\*\//g, "");
|
|
3
|
+
}
|
|
4
|
+
export function hasDefaultExport(code, _filePath) {
|
|
5
|
+
const stripped = stripComments(code);
|
|
6
|
+
return (/export\s+default\s/.test(stripped) ||
|
|
7
|
+
/export\s*\{[^}]*\bas\s+default\b[^}]*}/.test(stripped));
|
|
8
|
+
}
|
|
9
|
+
//# sourceMappingURL=validate-view.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-view.js","sourceRoot":"","sources":["../../../src/web/plugin/validate-view.ts"],"names":[],"mappings":"AAAA,SAAS,aAAa,CAAC,IAAY;IACjC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,mBAAmB,EAAE,EAAE,CAAC,CAAC;AACxE,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,IAAY,EAAE,SAAkB;IAC/D,MAAM,QAAQ,GAAG,aAAa,CAAC,IAAI,CAAC,CAAC;IACrC,OAAO,CACL,oBAAoB,CAAC,IAAI,CAAC,QAAQ,CAAC;QACnC,wCAAwC,CAAC,IAAI,CAAC,QAAQ,CAAC,CACxD,CAAC;AACJ,CAAC","sourcesContent":["function stripComments(code: string): string {\n return code.replace(/\\/\\/.*$/gm, \"\").replace(/\\/\\*[\\s\\S]*?\\*\\//g, \"\");\n}\n\nexport function hasDefaultExport(code: string, _filePath?: string): boolean {\n const stripped = stripComments(code);\n return (\n /export\\s+default\\s/.test(stripped) ||\n /export\\s*\\{[^}]*\\bas\\s+default\\b[^}]*}/.test(stripped)\n );\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { describe, expect, it } from "vitest";
|
|
2
|
+
import { hasDefaultExport } from "./validate-view.js";
|
|
3
|
+
describe("hasDefaultExport", () => {
|
|
4
|
+
it("detects export default declaration", () => {
|
|
5
|
+
expect(hasDefaultExport("export default MyView;")).toBe(true);
|
|
6
|
+
});
|
|
7
|
+
it("detects export default function", () => {
|
|
8
|
+
expect(hasDefaultExport("export default function MyView() {}")).toBe(true);
|
|
9
|
+
});
|
|
10
|
+
it("detects re-export as default", () => {
|
|
11
|
+
expect(hasDefaultExport("export { Foo as default };")).toBe(true);
|
|
12
|
+
});
|
|
13
|
+
it("returns false when no default export", () => {
|
|
14
|
+
expect(hasDefaultExport("export const Foo = 1;")).toBe(false);
|
|
15
|
+
});
|
|
16
|
+
it("ignores commented-out default exports", () => {
|
|
17
|
+
const code = `
|
|
18
|
+
// export default MyView;
|
|
19
|
+
/* export default MyView; */
|
|
20
|
+
`;
|
|
21
|
+
expect(hasDefaultExport(code)).toBe(false);
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
//# sourceMappingURL=validate-view.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate-view.test.js","sourceRoot":"","sources":["../../../src/web/plugin/validate-view.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAEtD,QAAQ,CAAC,kBAAkB,EAAE,GAAG,EAAE;IAChC,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,CAAC,gBAAgB,CAAC,wBAAwB,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,iCAAiC,EAAE,GAAG,EAAE;QACzC,MAAM,CAAC,gBAAgB,CAAC,qCAAqC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC7E,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAG,EAAE;QACtC,MAAM,CAAC,gBAAgB,CAAC,4BAA4B,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,CAAC,gBAAgB,CAAC,uBAAuB,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChE,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,uCAAuC,EAAE,GAAG,EAAE;QAC/C,MAAM,IAAI,GAAG;;;KAGZ,CAAC;QACF,MAAM,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC7C,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it } from \"vitest\";\nimport { hasDefaultExport } from \"./validate-view.js\";\n\ndescribe(\"hasDefaultExport\", () => {\n it(\"detects export default declaration\", () => {\n expect(hasDefaultExport(\"export default MyView;\")).toBe(true);\n });\n\n it(\"detects export default function\", () => {\n expect(hasDefaultExport(\"export default function MyView() {}\")).toBe(true);\n });\n\n it(\"detects re-export as default\", () => {\n expect(hasDefaultExport(\"export { Foo as default };\")).toBe(true);\n });\n\n it(\"returns false when no default export\", () => {\n expect(hasDefaultExport(\"export const Foo = 1;\")).toBe(false);\n });\n\n it(\"ignores commented-out default exports\", () => {\n const code = `\n // export default MyView;\n /* export default MyView; */\n `;\n expect(hasDefaultExport(code)).toBe(false);\n });\n});\n"]}
|
|
@@ -6,7 +6,11 @@ const colors = {
|
|
|
6
6
|
};
|
|
7
7
|
export function installOpenAILoggingProxy() {
|
|
8
8
|
if (typeof window === "undefined" || !window.openai) {
|
|
9
|
-
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const descriptor = Object.getOwnPropertyDescriptor(window, "openai");
|
|
12
|
+
if (descriptor?.configurable === false || descriptor?.writable === false) {
|
|
13
|
+
console.warn("[openai-proxy] window.openai is not configurable or writable, skipping proxy installation");
|
|
10
14
|
return;
|
|
11
15
|
}
|
|
12
16
|
const originalOpenAI = window.openai;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../src/web/proxy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,SAAS;CACR,CAAC;AAEX,MAAM,UAAU,yBAAyB;IACvC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,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EAC1B,QAAQ,CACT,CAAC;wBACF,OAAO,CAAC,QAAQ,EAAE,CAAC;wBACnB,OAAO,QAAQ,CAAC;oBAClB,CAAC,EACD,CAAC,KAAc,EAAE,EAAE;wBACjB,OAAO,CAAC,KAAK,CAAC,eAAe,EAAE,UAAU,MAAM,CAAC,KAAK,EAAE,EAAE,KAAK,CAAC,CAAC;wBAChE,OAAO,CAAC,QAAQ,EAAE,CAAC;wBACnB,MAAM,KAAK,CAAC;oBACd,CAAC,CACF,CAAC;gBACJ,CAAC;gBAED,OAAO,CAAC,GAAG,CAAC,eAAe,EAAE,UAAU,MAAM,CAAC,OAAO,EAAE,EAAE,MAAM,CAAC,CAAC;gBACjE,OAAO,CAAC,QAAQ,EAAE,CAAC;gBAEnB,OAAO,MAAM,CAAC;YAChB,CAAC,CAAC;QACJ,CAAC;QAED,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ;YAC/B,OAAO,CAAC,GAAG,CACT,yBAAyB,MAAM,CAAC,IAAI,CAAC,EAAE,EACvC,UAAU,MAAM,CAAC,KAAK,EAAE,EACxB,UAAU,MAAM,CAAC,IAAI,EAAE,EACvB,UAAU,MAAM,CAAC,OAAO,qBAAqB,EAC7C,GAAG,EACH,KAAK,CACN,CAAC;YAEF,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEnD,OAAO,CAAC,GAAG,CACT,8DAA8D,EAC9D,UAAU,MAAM,CAAC,KAAK,EAAE,EACxB,UAAU,MAAM,CAAC,IAAI,EAAE,CACxB,CAAC;AACJ,CAAC","sourcesContent":["const colors = {\n brand: \"#6366f1\",\n info: \"#22223b\",\n success: \"#22c55e\",\n error: \"#ef4444\",\n} as const;\n\nexport function installOpenAILoggingProxy() {\n if (typeof window === \"undefined\" || !window.openai) {\n return;\n }\n\n const descriptor = Object.getOwnPropertyDescriptor(window, \"openai\");\n if (descriptor?.configurable === false || descriptor?.writable === false) {\n console.warn(\n \"[openai-proxy] window.openai is not configurable or writable, skipping proxy installation\",\n );\n return;\n }\n\n const originalOpenAI = window.openai;\n\n const handler: ProxyHandler<typeof originalOpenAI> = {\n get(target, prop, receiver) {\n const value = Reflect.get(target, prop, receiver);\n\n if (typeof value !== \"function\") {\n return value;\n }\n\n return (...args: unknown[]) => {\n const methodName = String(prop);\n\n console.group(\n `%c[openai] %cmethod %c${methodName}`,\n `color: ${colors.brand}; font-weight: normal`,\n `color: ${colors.info}; font-weight: normal`,\n `color: ${colors.success}`,\n );\n console.log(\"%c← args:\", `color: ${colors.info}`, args);\n\n const result = value.apply(target, args);\n\n if (result && typeof result.then === \"function\") {\n return result.then(\n (resolved: unknown) => {\n console.log(\n \"%c→ resolved:\",\n `color: ${colors.success}`,\n resolved,\n );\n console.groupEnd();\n return resolved;\n },\n (error: unknown) => {\n console.error(\"%c→ rejected:\", `color: ${colors.error}`, error);\n console.groupEnd();\n throw error;\n },\n );\n }\n\n console.log(\"%c→ returned:\", `color: ${colors.success}`, result);\n console.groupEnd();\n\n return result;\n };\n },\n\n set(target, prop, value, receiver) {\n console.log(\n `%c[openai] %cupdate %c${String(prop)}`,\n `color: ${colors.brand}`,\n `color: ${colors.info}`,\n `color: ${colors.success}; font-weight: bold`,\n \"←\",\n value,\n );\n\n return Reflect.set(target, prop, value, receiver);\n },\n };\n\n window.openai = new Proxy(originalOpenAI, handler);\n\n console.log(\n \"%c[openai-proxy] %cInstalled logging proxy for window.openai\",\n `color: ${colors.brand}`,\n `color: ${colors.info}`,\n );\n}\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
declare module "react" {
|
|
3
|
+
interface HTMLAttributes<T> {
|
|
4
|
+
"data-llm"?: string;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
7
|
+
/** Shorthand for an arbitrary plain object — `Record<string, unknown>`. */
|
|
8
|
+
export type UnknownObject = Record<string, unknown>;
|
|
9
|
+
/** Flatten an intersection so it appears as a single object type in hovers and error messages. */
|
|
10
|
+
export type Prettify<T> = {
|
|
11
|
+
[K in keyof T]: T[K];
|
|
12
|
+
} & {};
|
|
13
|
+
/** Widen `T` to also satisfy {@link UnknownObject}, useful for tool input/output narrowing. */
|
|
14
|
+
export type Objectify<T> = T & UnknownObject;
|
|
15
|
+
type RequiredKeys<T> = {
|
|
16
|
+
[K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
|
|
17
|
+
}[keyof T];
|
|
18
|
+
/** `true` if `T` has at least one required key, `false` if every key is optional. */
|
|
19
|
+
export type HasRequiredKeys<T> = RequiredKeys<T> extends never ? false : true;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,CAAC","sourcesContent":["import \"react\";\n\ndeclare module \"react\" {\n interface HTMLAttributes<T> {\n \"data-llm\"?: string;\n }\n}\n\n/** Shorthand for an arbitrary plain object — `Record<string, unknown>`. */\nexport type UnknownObject = Record<string, unknown>;\n\n/** Flatten an intersection so it appears as a single object type in hovers and error messages. */\nexport type Prettify<T> = { [K in keyof T]: T[K] } & {};\n/** Widen `T` to also satisfy {@link UnknownObject}, useful for tool input/output narrowing. */\nexport type Objectify<T> = T & UnknownObject;\n\ntype RequiredKeys<T> = {\n [K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;\n}[keyof T];\n/** `true` if `T` has at least one required key, `false` if every key is optional. */\nexport type HasRequiredKeys<T> = RequiredKeys<T> extends never ? false : true;\n"]}
|
package/package.json
CHANGED
|
@@ -1,19 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skybridge",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
4
|
-
"description": "Skybridge is a framework for building ChatGPT
|
|
3
|
+
"version": "0.0.0-dev.fc2b815",
|
|
4
|
+
"description": "Skybridge is a framework for building ChatGPT and MCP Apps",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/alpic-ai/skybridge.git"
|
|
8
|
+
},
|
|
5
9
|
"type": "module",
|
|
10
|
+
"engines": {
|
|
11
|
+
"node": ">=22.22.3"
|
|
12
|
+
},
|
|
6
13
|
"files": [
|
|
7
|
-
"dist"
|
|
14
|
+
"dist",
|
|
15
|
+
"README.md",
|
|
16
|
+
"tsconfig.base.json"
|
|
8
17
|
],
|
|
9
18
|
"exports": {
|
|
19
|
+
"./tsconfig": "./tsconfig.base.json",
|
|
20
|
+
"./tsconfig.json": "./tsconfig.base.json",
|
|
10
21
|
"./server": {
|
|
11
|
-
"types": "./dist/
|
|
12
|
-
"default": "./dist/
|
|
22
|
+
"types": "./dist/server/index.d.ts",
|
|
23
|
+
"default": "./dist/server/index.js"
|
|
13
24
|
},
|
|
14
25
|
"./web": {
|
|
15
|
-
"types": "./dist/
|
|
16
|
-
"default": "./dist/
|
|
26
|
+
"types": "./dist/web/index.d.ts",
|
|
27
|
+
"default": "./dist/web/index.js"
|
|
28
|
+
},
|
|
29
|
+
"./vite": {
|
|
30
|
+
"types": "./dist/web/plugin/plugin.d.ts",
|
|
31
|
+
"default": "./dist/web/plugin/plugin.js"
|
|
17
32
|
}
|
|
18
33
|
},
|
|
19
34
|
"keywords": [
|
|
@@ -25,45 +40,75 @@
|
|
|
25
40
|
"author": "Frédéric Barthelet",
|
|
26
41
|
"license": "ISC",
|
|
27
42
|
"peerDependencies": {
|
|
28
|
-
"@modelcontextprotocol/sdk": ">=1.
|
|
43
|
+
"@modelcontextprotocol/sdk": ">=1.27.0",
|
|
44
|
+
"@skybridge/devtools": "^1.0.0",
|
|
45
|
+
"nodemon": ">=3.0.0",
|
|
29
46
|
"react": ">=18.0.0",
|
|
30
|
-
"react-dom": ">=18.0.0"
|
|
47
|
+
"react-dom": ">=18.0.0",
|
|
48
|
+
"vite": ">=7.3.1"
|
|
31
49
|
},
|
|
32
50
|
"dependencies": {
|
|
33
|
-
"@babel/core": "^7.
|
|
34
|
-
"
|
|
35
|
-
"
|
|
36
|
-
"
|
|
51
|
+
"@babel/core": "^7.29.0",
|
|
52
|
+
"@modelcontextprotocol/ext-apps": "^1.7.2",
|
|
53
|
+
"@oclif/core": "^4.11.3",
|
|
54
|
+
"ci-info": "^4.4.0",
|
|
55
|
+
"cors": "^2.8.6",
|
|
56
|
+
"cross-spawn": "^7.0.6",
|
|
57
|
+
"dequal": "^2.0.3",
|
|
58
|
+
"es-toolkit": "^1.46.1",
|
|
59
|
+
"express": "^5.2.1",
|
|
60
|
+
"handlebars": "^4.7.9",
|
|
61
|
+
"ink": "^7.0.3",
|
|
62
|
+
"open": "^11.0.0",
|
|
63
|
+
"posthog-node": "^5.35.1",
|
|
37
64
|
"superjson": "^2.2.6",
|
|
38
|
-
"
|
|
39
|
-
"zustand": "^5.0.9"
|
|
65
|
+
"zustand": "^5.0.13"
|
|
40
66
|
},
|
|
41
67
|
"devDependencies": {
|
|
42
|
-
"@
|
|
43
|
-
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
68
|
+
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
44
69
|
"@testing-library/dom": "^10.4.1",
|
|
45
|
-
"@testing-library/react": "^16.3.
|
|
70
|
+
"@testing-library/react": "^16.3.2",
|
|
46
71
|
"@total-typescript/tsconfig": "^1.0.4",
|
|
47
72
|
"@types/babel__core": "^7.20.5",
|
|
48
73
|
"@types/cors": "^2.8.19",
|
|
49
|
-
"@types/
|
|
50
|
-
"@types/
|
|
51
|
-
"@types/
|
|
52
|
-
"@types/
|
|
53
|
-
"@types/react
|
|
54
|
-
"@
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
74
|
+
"@types/cross-spawn": "^6.0.6",
|
|
75
|
+
"@types/express": "^5.0.6",
|
|
76
|
+
"@types/jsdom": "^28.0.3",
|
|
77
|
+
"@types/node": "^24.12.4",
|
|
78
|
+
"@types/react": "^19.2.15",
|
|
79
|
+
"@types/react-dom": "^19.2.3",
|
|
80
|
+
"@vitest/ui": "^4.1.7",
|
|
81
|
+
"jsdom": "^29.1.1",
|
|
82
|
+
"shx": "^0.4.0",
|
|
83
|
+
"ts-node": "^10.9.2",
|
|
84
|
+
"typescript": "^6.0.3",
|
|
85
|
+
"vite": "^8.0.0",
|
|
86
|
+
"vitest": "^4.1.7",
|
|
87
|
+
"zod": "^4.4.3"
|
|
88
|
+
},
|
|
89
|
+
"bin": {
|
|
90
|
+
"sb": "./bin/run.js",
|
|
91
|
+
"skybridge": "./bin/run.js"
|
|
92
|
+
},
|
|
93
|
+
"oclif": {
|
|
94
|
+
"bin": "skybridge",
|
|
95
|
+
"commands": "./dist/commands",
|
|
96
|
+
"dirname": "skybridge",
|
|
97
|
+
"topicSeparator": " ",
|
|
98
|
+
"helpClass": {
|
|
99
|
+
"target": "./dist/commands/create",
|
|
100
|
+
"identifier": "SkybridgeHelp"
|
|
101
|
+
},
|
|
102
|
+
"hooks": {
|
|
103
|
+
"finally": "./dist/cli/telemetry"
|
|
104
|
+
}
|
|
59
105
|
},
|
|
60
106
|
"scripts": {
|
|
61
|
-
"build": "
|
|
62
|
-
"build:templates": "
|
|
107
|
+
"build": "shx rm -rf dist && pnpm run build:templates && tsc",
|
|
108
|
+
"build:templates": "node scripts/precompile-templates.mjs",
|
|
63
109
|
"format": "biome check --write --error-on-warnings",
|
|
64
|
-
"test": "pnpm run test:unit && pnpm run test:
|
|
65
|
-
"test:unit": "vitest run",
|
|
66
|
-
"test:type": "tsc --noEmit",
|
|
110
|
+
"test": "pnpm run test:unit && pnpm run test:format",
|
|
111
|
+
"test:unit": "pnpm run build:templates && vitest run",
|
|
67
112
|
"test:format": "biome ci"
|
|
68
113
|
}
|
|
69
114
|
}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
// Module resolution options
|
|
4
|
+
"module": "NodeNext",
|
|
5
|
+
"esModuleInterop": true,
|
|
6
|
+
"verbatimModuleSyntax": true,
|
|
7
|
+
|
|
8
|
+
// Output options
|
|
9
|
+
"rootDir": "${configDir}/src",
|
|
10
|
+
"outDir": "${configDir}/dist",
|
|
11
|
+
"noEmit": false,
|
|
12
|
+
"incremental": true,
|
|
13
|
+
"sourceMap": true,
|
|
14
|
+
|
|
15
|
+
// Language and environment options
|
|
16
|
+
"target": "ES2022",
|
|
17
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
18
|
+
"jsx": "react-jsx",
|
|
19
|
+
|
|
20
|
+
// Type declarations
|
|
21
|
+
"types": ["node", "vite/client"],
|
|
22
|
+
|
|
23
|
+
// Strictness and checking options
|
|
24
|
+
"strict": true,
|
|
25
|
+
"skipLibCheck": true,
|
|
26
|
+
"forceConsistentCasingInFileNames": true,
|
|
27
|
+
|
|
28
|
+
// Code quality & diagnostics
|
|
29
|
+
"noUnusedLocals": true,
|
|
30
|
+
"noUnusedParameters": true,
|
|
31
|
+
"noFallthroughCasesInSwitch": true
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { type RequestHandler } from "express";
|
|
2
|
-
/**
|
|
3
|
-
* Serve the built devtools React app
|
|
4
|
-
* This router serves static files from the devtools's dist directory.
|
|
5
|
-
* It should be installed at the application root, like so:
|
|
6
|
-
*
|
|
7
|
-
* const app = express();
|
|
8
|
-
*
|
|
9
|
-
* if (env.NODE_ENV !== "production") {
|
|
10
|
-
* app.use(await devtoolsStaticServer(server));
|
|
11
|
-
* app.use(await widgetsDevServer());
|
|
12
|
-
* ^^^^^^^^ Make sure to install the devtoolsStaticServer before the widgetsDevServer
|
|
13
|
-
* }
|
|
14
|
-
*/
|
|
15
|
-
export declare const devtoolsStaticServer: () => Promise<RequestHandler>;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
-
import { createRequire } from "node:module";
|
|
3
|
-
import path from "node:path";
|
|
4
|
-
import cors from "cors";
|
|
5
|
-
import express, {} from "express";
|
|
6
|
-
const require = createRequire(import.meta.url);
|
|
7
|
-
/**
|
|
8
|
-
* Serve the built devtools React app
|
|
9
|
-
* This router serves static files from the devtools's dist directory.
|
|
10
|
-
* It should be installed at the application root, like so:
|
|
11
|
-
*
|
|
12
|
-
* const app = express();
|
|
13
|
-
*
|
|
14
|
-
* if (env.NODE_ENV !== "production") {
|
|
15
|
-
* app.use(await devtoolsStaticServer(server));
|
|
16
|
-
* app.use(await widgetsDevServer());
|
|
17
|
-
* ^^^^^^^^ Make sure to install the devtoolsStaticServer before the widgetsDevServer
|
|
18
|
-
* }
|
|
19
|
-
*/
|
|
20
|
-
export const devtoolsStaticServer = async () => {
|
|
21
|
-
const router = express.Router();
|
|
22
|
-
let devtoolsPath;
|
|
23
|
-
const devtoolsPackagePath = require.resolve("@skybridge/devtools/package.json");
|
|
24
|
-
devtoolsPath = path.join(path.dirname(devtoolsPackagePath), "dist");
|
|
25
|
-
if (!existsSync(devtoolsPath)) {
|
|
26
|
-
throw new Error("@skybridge/devtools dist folder not found. The package is installed but not built. Please build it first.");
|
|
27
|
-
}
|
|
28
|
-
router.use(cors());
|
|
29
|
-
router.use(express.static(devtoolsPath));
|
|
30
|
-
router.get("/", (_req, res, next) => {
|
|
31
|
-
const indexHtmlPath = path.join(devtoolsPath, "index.html");
|
|
32
|
-
try {
|
|
33
|
-
const indexHtml = readFileSync(indexHtmlPath, "utf-8");
|
|
34
|
-
res.setHeader("Content-Type", "text/html");
|
|
35
|
-
res.send(indexHtml);
|
|
36
|
-
}
|
|
37
|
-
catch (error) {
|
|
38
|
-
next(error);
|
|
39
|
-
}
|
|
40
|
-
});
|
|
41
|
-
return router;
|
|
42
|
-
};
|
|
43
|
-
//# sourceMappingURL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MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;YACvD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;YAC3C,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
export { devtoolsStaticServer } from "./devtoolsStaticServer.js";
|
|
2
|
-
export type { AnyToolRegistry, InferTools, ToolInput, ToolNames, ToolOutput, ToolResponseMetadata, } from "./inferUtilityTypes.js";
|
|
3
|
-
export type { McpServerTypes, ToolDef } from "./server.js";
|
|
4
|
-
export { McpServer } from "./server.js";
|
|
5
|
-
export { widgetsDevServer } from "./widgetsDevServer.js";
|
package/dist/src/server/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAUjE,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"inferUtilityTypes.js","sourceRoot":"","sources":["../../../src/server/inferUtilityTypes.ts"],"names":[],"mappings":""}
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { McpServer as McpServerBase, type RegisteredTool } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type { AnySchema, SchemaOutput, ZodRawShapeCompat } from "@modelcontextprotocol/sdk/server/zod-compat.js";
|
|
3
|
-
import type { RequestHandlerExtra } from "@modelcontextprotocol/sdk/shared/protocol.js";
|
|
4
|
-
import type { CallToolResult, Resource, ServerNotification, ServerRequest, ToolAnnotations } from "@modelcontextprotocol/sdk/types.js";
|
|
5
|
-
export type ToolDef<TInput = unknown, TOutput = unknown, TResponseMetadata = unknown> = {
|
|
6
|
-
input: TInput;
|
|
7
|
-
output: TOutput;
|
|
8
|
-
responseMetadata: TResponseMetadata;
|
|
9
|
-
};
|
|
10
|
-
type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType">;
|
|
11
|
-
type McpServerOriginalToolConfig = Omit<Parameters<typeof McpServerBase.prototype.registerTool<ZodRawShapeCompat, ZodRawShapeCompat>>[1], "inputSchema" | "outputSchema">;
|
|
12
|
-
type ExtractStructuredContent<T> = T extends {
|
|
13
|
-
structuredContent: infer SC;
|
|
14
|
-
} ? SC : never;
|
|
15
|
-
type ExtractMeta<T> = Extract<T, {
|
|
16
|
-
_meta: unknown;
|
|
17
|
-
}> extends {
|
|
18
|
-
_meta: infer M;
|
|
19
|
-
} ? M : unknown;
|
|
20
|
-
/**
|
|
21
|
-
* Type-level marker interface for cross-package type inference.
|
|
22
|
-
* This enables TypeScript to infer tool types across package boundaries
|
|
23
|
-
* using structural typing on the $types property, rather than relying on
|
|
24
|
-
* class generic inference which fails when McpServer comes from different
|
|
25
|
-
* package installations.
|
|
26
|
-
*
|
|
27
|
-
* Inspired by tRPC's _def pattern and Hono's type markers.
|
|
28
|
-
*/
|
|
29
|
-
export interface McpServerTypes<TTools extends Record<string, ToolDef>> {
|
|
30
|
-
readonly tools: TTools;
|
|
31
|
-
}
|
|
32
|
-
type Simplify<T> = {
|
|
33
|
-
[K in keyof T]: T[K];
|
|
34
|
-
};
|
|
35
|
-
type ShapeOutput<Shape extends ZodRawShapeCompat> = Simplify<{
|
|
36
|
-
[K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? never : K]: SchemaOutput<Shape[K]>;
|
|
37
|
-
} & {
|
|
38
|
-
[K in keyof Shape as undefined extends SchemaOutput<Shape[K]> ? K : never]?: SchemaOutput<Shape[K]>;
|
|
39
|
-
}>;
|
|
40
|
-
type AddTool<TTools, TName extends string, TInput extends ZodRawShapeCompat, TOutput, TResponseMetadata = unknown> = McpServer<TTools & {
|
|
41
|
-
[K in TName]: ToolDef<ShapeOutput<TInput>, TOutput, TResponseMetadata>;
|
|
42
|
-
}>;
|
|
43
|
-
type ToolConfig<TInput extends ZodRawShapeCompat | AnySchema> = {
|
|
44
|
-
title?: string;
|
|
45
|
-
description?: string;
|
|
46
|
-
inputSchema?: TInput;
|
|
47
|
-
outputSchema?: ZodRawShapeCompat | AnySchema;
|
|
48
|
-
annotations?: ToolAnnotations;
|
|
49
|
-
_meta?: Record<string, unknown>;
|
|
50
|
-
};
|
|
51
|
-
type ToolHandler<TInput extends ZodRawShapeCompat, TReturn extends CallToolResult = CallToolResult> = (args: ShapeOutput<TInput>, extra: RequestHandlerExtra<ServerRequest, ServerNotification>) => TReturn | Promise<TReturn>;
|
|
52
|
-
export declare class McpServer<TTools extends Record<string, ToolDef> = Record<never, ToolDef>> extends McpServerBase {
|
|
53
|
-
readonly $types: McpServerTypes<TTools>;
|
|
54
|
-
registerWidget<TName extends string, TInput extends ZodRawShapeCompat, TReturn extends CallToolResult>(name: TName, resourceConfig: McpServerOriginalResourceConfig, toolConfig: McpServerOriginalToolConfig & {
|
|
55
|
-
inputSchema?: TInput;
|
|
56
|
-
outputSchema?: ZodRawShapeCompat | AnySchema;
|
|
57
|
-
}, toolCallback: ToolHandler<TInput, TReturn>): AddTool<TTools, TName, TInput, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
58
|
-
registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends CallToolResult>(name: TName, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
59
|
-
registerTool<InputArgs extends ZodRawShapeCompat>(name: string, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs>): RegisteredTool;
|
|
60
|
-
private lookupDistFile;
|
|
61
|
-
}
|
|
62
|
-
export {};
|
|
@@ -1,62 +0,0 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
2
|
-
import path from "node:path";
|
|
3
|
-
import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
4
|
-
import { templateHelper } from "./templateHelper.js";
|
|
5
|
-
export class McpServer extends McpServerBase {
|
|
6
|
-
registerWidget(name, resourceConfig, toolConfig, toolCallback) {
|
|
7
|
-
const uri = `ui://widgets/${name}.html`;
|
|
8
|
-
const resourceMetadata = {
|
|
9
|
-
...(resourceConfig._meta ?? {}),
|
|
10
|
-
};
|
|
11
|
-
if (toolConfig.description !== undefined) {
|
|
12
|
-
resourceMetadata["openai/widgetDescription"] = toolConfig.description;
|
|
13
|
-
}
|
|
14
|
-
this.registerResource(name, uri, {
|
|
15
|
-
...resourceConfig,
|
|
16
|
-
_meta: resourceMetadata,
|
|
17
|
-
}, async (_uri, extra) => {
|
|
18
|
-
const serverUrl = process.env.NODE_ENV === "production"
|
|
19
|
-
? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ??
|
|
20
|
-
extra?.requestInfo?.headers?.host}`
|
|
21
|
-
: `http://localhost:3000`;
|
|
22
|
-
const html = process.env.NODE_ENV === "production"
|
|
23
|
-
? templateHelper.renderProduction({
|
|
24
|
-
serverUrl,
|
|
25
|
-
widgetFile: this.lookupDistFile(`src/widgets/${name}.tsx`),
|
|
26
|
-
styleFile: this.lookupDistFile("style.css"),
|
|
27
|
-
})
|
|
28
|
-
: templateHelper.renderDevelopment({
|
|
29
|
-
serverUrl,
|
|
30
|
-
widgetName: name,
|
|
31
|
-
});
|
|
32
|
-
return {
|
|
33
|
-
contents: [
|
|
34
|
-
{
|
|
35
|
-
uri,
|
|
36
|
-
mimeType: "text/html+skybridge",
|
|
37
|
-
text: html,
|
|
38
|
-
},
|
|
39
|
-
],
|
|
40
|
-
};
|
|
41
|
-
});
|
|
42
|
-
const toolMeta = {
|
|
43
|
-
...toolConfig._meta,
|
|
44
|
-
"openai/outputTemplate": uri,
|
|
45
|
-
"ui/resourceUri": uri,
|
|
46
|
-
};
|
|
47
|
-
this.registerTool(name, {
|
|
48
|
-
...toolConfig,
|
|
49
|
-
_meta: toolMeta,
|
|
50
|
-
}, toolCallback);
|
|
51
|
-
return this;
|
|
52
|
-
}
|
|
53
|
-
registerTool(name, config, cb) {
|
|
54
|
-
super.registerTool(name, config, cb);
|
|
55
|
-
return this;
|
|
56
|
-
}
|
|
57
|
-
lookupDistFile(key) {
|
|
58
|
-
const manifest = JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
59
|
-
return manifest[key]?.file;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
//# sourceMappingURL=server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,SAAS,IAAI,aAAa,GAG3B,MAAM,yCAAyC,CAAC;AAcjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA0HrD,MAAM,OAAO,SAEX,SAAQ,aAAa;IAGrB,cAAc,CAKZ,IAAW,EACX,cAA+C,EAC/C,UAGC,EACD,YAA0C;QAQ1C,MAAM,GAAG,GAAG,gBAAgB,IAAI,OAAO,CAAC;QACxC,MAAM,gBAAgB,GAAiB;YACrC,GAAG,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC;SAChC,CAAC;QACF,IAAI,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACzC,gBAAgB,CAAC,0BAA0B,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;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