skybridge 0.0.0-dev.ee1aba6 → 0.0.0-dev.ee1b9b9
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 +153 -0
- package/bin/run.js +0 -4
- package/dist/cli/build-helpers.d.ts +11 -0
- package/dist/cli/build-helpers.js +102 -0
- package/dist/cli/build-helpers.js.map +1 -0
- package/dist/cli/build-helpers.test.js +119 -0
- package/dist/cli/build-helpers.test.js.map +1 -0
- package/dist/cli/build-steps.d.ts +2 -0
- package/dist/cli/build-steps.js +73 -0
- package/dist/cli/build-steps.js.map +1 -0
- package/dist/cli/build-steps.test.js +52 -0
- package/dist/cli/build-steps.test.js.map +1 -0
- package/dist/cli/detect-port.d.ts +18 -0
- package/dist/cli/detect-port.js +50 -0
- package/dist/cli/detect-port.js.map +1 -0
- package/dist/cli/header.d.ts +1 -1
- package/dist/cli/header.js +1 -1
- package/dist/cli/header.js.map +1 -1
- package/dist/cli/resolve-views-dir.d.ts +1 -0
- package/dist/cli/resolve-views-dir.js +17 -0
- package/dist/cli/resolve-views-dir.js.map +1 -0
- package/dist/cli/run-command.js.map +1 -1
- package/dist/cli/run-plain.d.ts +18 -0
- package/dist/cli/run-plain.js +89 -0
- package/dist/cli/run-plain.js.map +1 -0
- package/dist/cli/telemetry.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.d.ts +1 -0
- package/dist/cli/tunnel-control-server.test.js +39 -0
- package/dist/cli/tunnel-control-server.test.js.map +1 -0
- package/dist/cli/tunnel-handler.d.ts +3 -0
- package/dist/cli/tunnel-handler.js +48 -0
- package/dist/cli/tunnel-handler.js.map +1 -0
- package/dist/cli/tunnel-handler.test.d.ts +1 -0
- package/dist/cli/tunnel-handler.test.js +105 -0
- package/dist/cli/tunnel-handler.test.js.map +1 -0
- package/dist/cli/tunnel.d.ts +57 -0
- package/dist/cli/tunnel.js +154 -0
- package/dist/cli/tunnel.js.map +1 -0
- package/dist/cli/tunnel.test.d.ts +1 -0
- package/dist/cli/tunnel.test.js +190 -0
- package/dist/cli/tunnel.test.js.map +1 -0
- package/dist/cli/types.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 +3 -2
- package/dist/cli/use-execute-steps.js +6 -1
- package/dist/cli/use-execute-steps.js.map +1 -1
- 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 +16 -0
- package/dist/cli/use-nodemon.js +84 -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 +15 -0
- package/dist/cli/use-typescript-check.js +97 -0
- package/dist/cli/use-typescript-check.js.map +1 -0
- package/dist/commands/build.d.ts +0 -3
- package/dist/commands/build.js +3 -16
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/create.d.ts +9 -0
- package/dist/commands/create.js +30 -0
- package/dist/commands/create.js.map +1 -0
- package/dist/commands/dev.d.ts +7 -1
- package/dist/commands/dev.js +117 -9
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.d.ts +3 -1
- package/dist/commands/start.js +37 -15
- package/dist/commands/start.js.map +1 -1
- 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.d.ts +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/discovery.d.ts +32 -0
- package/dist/server/auth/discovery.js +56 -0
- package/dist/server/auth/discovery.js.map +1 -0
- package/dist/server/auth/discovery.test.d.ts +1 -0
- package/dist/server/auth/discovery.test.js +93 -0
- package/dist/server/auth/discovery.test.js.map +1 -0
- package/dist/server/auth/index.d.ts +18 -0
- package/dist/server/auth/index.js +2 -0
- package/dist/server/auth/index.js.map +1 -0
- package/dist/server/auth/providers/auth0.d.ts +18 -0
- package/dist/server/auth/providers/auth0.js +31 -0
- package/dist/server/auth/providers/auth0.js.map +1 -0
- package/dist/server/auth/providers/auth0.test.d.ts +1 -0
- package/dist/server/auth/providers/auth0.test.js +48 -0
- package/dist/server/auth/providers/auth0.test.js.map +1 -0
- package/dist/server/auth/providers/clerk.d.ts +14 -0
- package/dist/server/auth/providers/clerk.js +16 -0
- package/dist/server/auth/providers/clerk.js.map +1 -0
- package/dist/server/auth/providers/clerk.test.d.ts +1 -0
- package/dist/server/auth/providers/clerk.test.js +28 -0
- package/dist/server/auth/providers/clerk.test.js.map +1 -0
- package/dist/server/auth/providers/custom.d.ts +30 -0
- package/dist/server/auth/providers/custom.js +40 -0
- package/dist/server/auth/providers/custom.js.map +1 -0
- package/dist/server/auth/providers/custom.test.d.ts +1 -0
- package/dist/server/auth/providers/custom.test.js +128 -0
- package/dist/server/auth/providers/custom.test.js.map +1 -0
- package/dist/server/auth/providers/descope.d.ts +15 -0
- package/dist/server/auth/providers/descope.js +35 -0
- package/dist/server/auth/providers/descope.js.map +1 -0
- package/dist/server/auth/providers/descope.test.d.ts +1 -0
- package/dist/server/auth/providers/descope.test.js +39 -0
- package/dist/server/auth/providers/descope.test.js.map +1 -0
- package/dist/server/auth/providers/shared.d.ts +2 -0
- package/dist/server/auth/providers/shared.js +6 -0
- package/dist/server/auth/providers/shared.js.map +1 -0
- package/dist/server/auth/providers/shared.test.d.ts +1 -0
- package/dist/server/auth/providers/shared.test.js +10 -0
- package/dist/server/auth/providers/shared.test.js.map +1 -0
- package/dist/server/auth/providers/stytch.d.ts +12 -0
- package/dist/server/auth/providers/stytch.js +13 -0
- package/dist/server/auth/providers/stytch.js.map +1 -0
- package/dist/server/auth/providers/workos.d.ts +11 -0
- package/dist/server/auth/providers/workos.js +12 -0
- package/dist/server/auth/providers/workos.js.map +1 -0
- package/dist/server/auth/setup.d.ts +4 -0
- package/dist/server/auth/setup.js +51 -0
- package/dist/server/auth/setup.js.map +1 -0
- package/dist/server/auth/setup.test.d.ts +1 -0
- package/dist/server/auth/setup.test.js +185 -0
- package/dist/server/auth/setup.test.js.map +1 -0
- package/dist/server/auth/verify.d.ts +12 -0
- package/dist/server/auth/verify.js +38 -0
- package/dist/server/auth/verify.js.map +1 -0
- package/dist/server/auth/verify.test.d.ts +1 -0
- package/dist/server/auth/verify.test.js +100 -0
- package/dist/server/auth/verify.test.js.map +1 -0
- package/dist/server/auth.d.ts +20 -0
- package/dist/server/auth.js +28 -0
- package/dist/server/auth.js.map +1 -0
- package/dist/server/build-manifest.test.d.ts +1 -0
- package/dist/server/build-manifest.test.js +27 -0
- package/dist/server/build-manifest.test.js.map +1 -0
- package/dist/server/content-helpers.d.ts +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.d.ts +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.d.ts +1 -0
- package/dist/server/express.test.js +491 -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 +15 -3
- package/dist/server/index.js +12 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/inferUtilityTypes.d.ts +6 -6
- package/dist/server/inferUtilityTypes.js.map +1 -1
- 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.d.ts +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.d.ts +1 -0
- package/dist/server/middleware.test.js +493 -0
- package/dist/server/middleware.test.js.map +1 -0
- package/dist/server/requestOrigin.d.ts +7 -0
- package/dist/server/requestOrigin.js +25 -0
- package/dist/server/requestOrigin.js.map +1 -0
- package/dist/server/server.d.ts +387 -59
- package/dist/server/server.js +628 -97
- package/dist/server/server.js.map +1 -1
- package/dist/server/skills-integration.test.d.ts +1 -0
- package/dist/server/skills-integration.test.js +63 -0
- package/dist/server/skills-integration.test.js.map +1 -0
- package/dist/server/skills.d.ts +23 -0
- package/dist/server/skills.js +178 -0
- package/dist/server/skills.js.map +1 -0
- package/dist/server/skills.test.d.ts +1 -0
- package/dist/server/skills.test.js +210 -0
- package/dist/server/skills.test.js.map +1 -0
- package/dist/server/templateHelper.d.ts +5 -7
- package/dist/server/templateHelper.js +3 -22
- package/dist/server/templateHelper.js.map +1 -1
- package/dist/server/templates.generated.d.ts +4 -0
- package/dist/server/templates.generated.js +47 -0
- package/dist/server/templates.generated.js.map +1 -0
- package/dist/server/tunnel-proxy-router.d.ts +7 -0
- package/dist/server/tunnel-proxy-router.js +110 -0
- package/dist/server/tunnel-proxy-router.js.map +1 -0
- package/dist/server/tunnel-proxy-router.test.d.ts +1 -0
- package/dist/server/tunnel-proxy-router.test.js +229 -0
- package/dist/server/tunnel-proxy-router.test.js.map +1 -0
- package/dist/server/view-name.test-d.d.ts +1 -0
- package/dist/server/view-name.test-d.js +8 -0
- package/dist/server/view-name.test-d.js.map +1 -0
- package/dist/server/view-resource-resolution.test.d.ts +6 -0
- package/dist/server/view-resource-resolution.test.js +171 -0
- package/dist/server/view-resource-resolution.test.js.map +1 -0
- package/dist/server/viewsDevServer.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 +13 -21
- package/dist/test/utils.js +42 -37
- package/dist/test/utils.js.map +1 -1
- package/dist/test/view.test.d.ts +1 -0
- package/dist/test/view.test.js +536 -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/adaptor.d.ts +51 -0
- package/dist/web/bridges/adaptor.js +330 -0
- package/dist/web/bridges/adaptor.js.map +1 -0
- package/dist/web/bridges/adaptor.test.d.ts +1 -0
- package/dist/web/bridges/adaptor.test.js +208 -0
- package/dist/web/bridges/adaptor.test.js.map +1 -0
- package/dist/web/bridges/apps-sdk/bridge.d.ts +7 -2
- package/dist/web/bridges/apps-sdk/bridge.js +15 -3
- package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
- package/dist/web/bridges/apps-sdk/index.d.ts +1 -2
- package/dist/web/bridges/apps-sdk/index.js +0 -1
- package/dist/web/bridges/apps-sdk/index.js.map +1 -1
- package/dist/web/bridges/apps-sdk/types.d.ts +39 -27
- package/dist/web/bridges/apps-sdk/types.js.map +1 -1
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.d.ts +11 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +11 -0
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
- package/dist/web/bridges/get-adaptor.d.ts +7 -0
- package/dist/web/bridges/get-adaptor.js +9 -7
- package/dist/web/bridges/get-adaptor.js.map +1 -1
- package/dist/web/bridges/get-adaptor.test.d.ts +1 -0
- package/dist/web/bridges/get-adaptor.test.js +32 -0
- package/dist/web/bridges/get-adaptor.test.js.map +1 -0
- package/dist/web/bridges/index.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.d.ts +27 -31
- package/dist/web/bridges/mcp-app/bridge.js +109 -198
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.test.d.ts +1 -0
- package/dist/web/bridges/mcp-app/bridge.test.js +17 -0
- package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -0
- package/dist/web/bridges/mcp-app/index.d.ts +0 -1
- package/dist/web/bridges/mcp-app/index.js +0 -1
- package/dist/web/bridges/mcp-app/index.js.map +1 -1
- package/dist/web/bridges/mcp-app/types.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +17 -3
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +14 -2
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -41
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
- package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
- package/dist/web/bridges/mcp-app/view-tools.test.js +143 -0
- package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
- package/dist/web/bridges/types.d.ts +153 -13
- package/dist/web/bridges/types.js +14 -1
- package/dist/web/bridges/types.js.map +1 -1
- package/dist/web/bridges/types.test.d.ts +1 -0
- package/dist/web/bridges/types.test.js +19 -0
- package/dist/web/bridges/types.test.js.map +1 -0
- package/dist/web/bridges/use-host-context.d.ts +5 -0
- package/dist/web/bridges/use-host-context.js +5 -0
- package/dist/web/bridges/use-host-context.js.map +1 -1
- package/dist/web/components/modal-provider.d.ts +4 -0
- package/dist/web/components/modal-provider.js +46 -0
- package/dist/web/components/modal-provider.js.map +1 -0
- package/dist/web/create-store.d.ts +26 -0
- package/dist/web/create-store.js +43 -3
- package/dist/web/create-store.js.map +1 -1
- package/dist/web/create-store.test.js +31 -25
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.d.ts +35 -2
- package/dist/web/data-llm.js +31 -3
- package/dist/web/data-llm.js.map +1 -1
- package/dist/web/data-llm.test.js +50 -35
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +22 -18
- package/dist/web/generate-helpers.js +22 -18
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/generate-helpers.test-d.js +30 -28
- package/dist/web/generate-helpers.test-d.js.map +1 -1
- package/dist/web/generate-helpers.test.js.map +1 -1
- package/dist/web/helpers/state.d.ts +2 -2
- package/dist/web/helpers/state.js +11 -11
- package/dist/web/helpers/state.js.map +1 -1
- package/dist/web/helpers/state.test.js +9 -9
- package/dist/web/helpers/state.test.js.map +1 -1
- package/dist/web/hooks/index.d.ts +7 -2
- package/dist/web/hooks/index.js +6 -1
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/test/utils.d.ts +6 -2
- package/dist/web/hooks/test/utils.js +17 -2
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-call-tool.d.ts +45 -0
- package/dist/web/hooks/use-call-tool.js +28 -0
- package/dist/web/hooks/use-call-tool.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test.js +62 -27
- package/dist/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/web/hooks/use-display-mode.d.ts +23 -3
- package/dist/web/hooks/use-display-mode.js +20 -0
- package/dist/web/hooks/use-display-mode.js.map +1 -1
- package/dist/web/hooks/use-display-mode.test-d.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.js +56 -20
- package/dist/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/web/hooks/use-download.d.ts +5 -0
- package/dist/web/hooks/use-download.js +8 -0
- package/dist/web/hooks/use-download.js.map +1 -0
- package/dist/web/hooks/use-download.test.d.ts +1 -0
- package/dist/web/hooks/use-download.test.js +103 -0
- package/dist/web/hooks/use-download.test.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +35 -6
- package/dist/web/hooks/use-files.js +37 -2
- package/dist/web/hooks/use-files.js.map +1 -1
- package/dist/web/hooks/use-files.test.js +36 -3
- package/dist/web/hooks/use-files.test.js.map +1 -1
- package/dist/web/hooks/use-layout.d.ts +3 -1
- package/dist/web/hooks/use-layout.js +2 -0
- package/dist/web/hooks/use-layout.js.map +1 -1
- package/dist/web/hooks/use-layout.test.js +62 -29
- package/dist/web/hooks/use-layout.test.js.map +1 -1
- package/dist/web/hooks/use-open-external.d.ts +20 -1
- package/dist/web/hooks/use-open-external.js +17 -1
- package/dist/web/hooks/use-open-external.js.map +1 -1
- package/dist/web/hooks/use-open-external.test.js +38 -13
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-register-view-tool.d.ts +38 -0
- package/dist/web/hooks/use-register-view-tool.js +50 -0
- package/dist/web/hooks/use-register-view-tool.js.map +1 -0
- package/dist/web/hooks/use-request-close.d.ts +16 -0
- package/dist/web/hooks/use-request-close.js +21 -0
- package/dist/web/hooks/use-request-close.js.map +1 -0
- package/dist/web/hooks/use-request-close.test.d.ts +1 -0
- package/dist/web/hooks/use-request-close.test.js +47 -0
- package/dist/web/hooks/use-request-close.test.js.map +1 -0
- package/dist/web/hooks/use-request-modal.d.ts +18 -3
- package/dist/web/hooks/use-request-modal.js +25 -8
- package/dist/web/hooks/use-request-modal.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js +15 -1
- package/dist/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/web/hooks/use-request-size.d.ts +20 -0
- package/dist/web/hooks/use-request-size.js +24 -0
- package/dist/web/hooks/use-request-size.js.map +1 -0
- package/dist/web/hooks/use-request-size.test.d.ts +1 -0
- package/dist/web/hooks/use-request-size.test.js +47 -0
- package/dist/web/hooks/use-request-size.test.js.map +1 -0
- package/dist/web/hooks/use-send-follow-up-message.d.ts +19 -1
- package/dist/web/hooks/use-send-follow-up-message.js +19 -2
- package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.d.ts +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 +63 -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 +53 -2
- package/dist/web/hooks/use-tool-info.js +30 -7
- package/dist/web/hooks/use-tool-info.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test-d.js +11 -29
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +43 -33
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.d.ts +2 -0
- package/dist/web/hooks/use-user.js +20 -2
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +101 -27
- package/dist/web/hooks/use-user.test.js.map +1 -1
- 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 +181 -0
- package/dist/web/hooks/use-view-state.test.js.map +1 -0
- package/dist/web/index.d.ts +1 -2
- package/dist/web/index.js +1 -2
- package/dist/web/index.js.map +1 -1
- 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.js.map +1 -1
- package/dist/web/plugin/plugin.d.ts +32 -1
- package/dist/web/plugin/plugin.js +167 -18
- package/dist/web/plugin/plugin.js.map +1 -1
- 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.js +1 -1
- package/dist/web/plugin/transform-data-llm.js.map +1 -1
- package/dist/web/plugin/transform-data-llm.test.js.map +1 -1
- package/dist/web/plugin/validate-view.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.js +0 -1
- package/dist/web/proxy.js.map +1 -1
- package/dist/web/types.d.ts +4 -0
- package/dist/web/types.js.map +1 -1
- package/package.json +59 -30
- package/tsconfig.base.json +33 -0
- package/dist/server/templates/development.hbs +0 -66
- package/dist/server/templates/production.hbs +0 -7
- package/dist/server/widgetsDevServer.d.ts +0 -12
- package/dist/server/widgetsDevServer.js +0 -47
- package/dist/server/widgetsDevServer.js.map +0 -1
- package/dist/test/widget.test.js +0 -255
- package/dist/test/widget.test.js.map +0 -1
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +0 -14
- package/dist/web/bridges/apps-sdk/adaptor.js +0 -39
- package/dist/web/bridges/apps-sdk/adaptor.js.map +0 -1
- package/dist/web/bridges/mcp-app/adaptor.d.ts +0 -19
- package/dist/web/bridges/mcp-app/adaptor.js +0 -145
- package/dist/web/bridges/mcp-app/adaptor.js.map +0 -1
- package/dist/web/hooks/use-widget-state.d.ts +0 -4
- package/dist/web/hooks/use-widget-state.js +0 -32
- package/dist/web/hooks/use-widget-state.js.map +0 -1
- package/dist/web/hooks/use-widget-state.test.js +0 -61
- package/dist/web/hooks/use-widget-state.test.js.map +0 -1
- package/dist/web/mount-widget.d.ts +0 -1
- package/dist/web/mount-widget.js +0 -19
- package/dist/web/mount-widget.js.map +0 -1
- /package/dist/{test/widget.test.d.ts → cli/build-helpers.test.d.ts} +0 -0
- /package/dist/{web/hooks/use-widget-state.test.d.ts → cli/build-steps.test.d.ts} +0 -0
|
@@ -0,0 +1,210 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
import { mkdirSync, mkdtempSync, symlinkSync, writeFileSync } from "node:fs";
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { join } from "node:path";
|
|
5
|
+
import { ResourceTemplate } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
6
|
+
import { describe, expect, it, vi } from "vitest";
|
|
7
|
+
import { discoverSkills, registerSkills, SKILL_INDEX_URI, skillUriToRelPath, } from "./skills.js";
|
|
8
|
+
function mkSkillDir(files) {
|
|
9
|
+
const root = mkdtempSync(join(tmpdir(), "skybridge-skills-"));
|
|
10
|
+
for (const [rel, content] of Object.entries(files)) {
|
|
11
|
+
const full = join(root, rel);
|
|
12
|
+
mkdirSync(join(full, ".."), { recursive: true });
|
|
13
|
+
writeFileSync(full, content);
|
|
14
|
+
}
|
|
15
|
+
return root;
|
|
16
|
+
}
|
|
17
|
+
const FM = (name, description) => `---\nname: ${name}\ndescription: ${description}\n---\n`;
|
|
18
|
+
describe("discoverSkills", () => {
|
|
19
|
+
it("discovers a skill with frontmatter, digest, and supporting files", () => {
|
|
20
|
+
const dir = mkSkillDir({
|
|
21
|
+
"git-workflow/SKILL.md": `${FM("git-workflow", "Team git conventions")}Body`,
|
|
22
|
+
"git-workflow/references/GUIDE.md": "# Guide",
|
|
23
|
+
});
|
|
24
|
+
const [skill, ...rest] = discoverSkills(dir);
|
|
25
|
+
expect(rest).toHaveLength(0);
|
|
26
|
+
expect(skill?.name).toBe("git-workflow");
|
|
27
|
+
expect(skill?.frontmatter).toMatchObject({
|
|
28
|
+
name: "git-workflow",
|
|
29
|
+
description: "Team git conventions",
|
|
30
|
+
});
|
|
31
|
+
expect(skill?.digest).toMatch(/^sha256:[a-f0-9]{64}$/);
|
|
32
|
+
expect(Object.keys(skill?.files ?? {}).sort()).toEqual([
|
|
33
|
+
"SKILL.md",
|
|
34
|
+
"references/GUIDE.md",
|
|
35
|
+
]);
|
|
36
|
+
});
|
|
37
|
+
it("returns [] for a missing directory and skips dirs without SKILL.md", () => {
|
|
38
|
+
expect(discoverSkills(join(tmpdir(), "does-not-exist-xyz"))).toEqual([]);
|
|
39
|
+
const dir = mkSkillDir({ "not-a-skill/README.md": "hi" });
|
|
40
|
+
expect(discoverSkills(dir)).toEqual([]);
|
|
41
|
+
});
|
|
42
|
+
it("parses a nested metadata map in frontmatter", () => {
|
|
43
|
+
const dir = mkSkillDir({
|
|
44
|
+
"s/SKILL.md": `---\nname: s\ndescription: d\nmetadata:\n version: "1.2"\n team: core\n---\n`,
|
|
45
|
+
});
|
|
46
|
+
expect(discoverSkills(dir)[0]?.frontmatter.metadata).toEqual({
|
|
47
|
+
version: "1.2",
|
|
48
|
+
team: "core",
|
|
49
|
+
});
|
|
50
|
+
});
|
|
51
|
+
it("throws on missing frontmatter", () => {
|
|
52
|
+
const dir = mkSkillDir({ "s/SKILL.md": "no frontmatter here" });
|
|
53
|
+
expect(() => discoverSkills(dir)).toThrow(/missing YAML frontmatter/);
|
|
54
|
+
});
|
|
55
|
+
it("throws when required fields are absent", () => {
|
|
56
|
+
const dir = mkSkillDir({ "s/SKILL.md": "---\nname: s\n---\n" });
|
|
57
|
+
expect(() => discoverSkills(dir)).toThrow(/Invalid skill frontmatter/);
|
|
58
|
+
});
|
|
59
|
+
it("throws when the frontmatter name does not match the directory", () => {
|
|
60
|
+
const dir = mkSkillDir({ "s/SKILL.md": FM("other", "d") });
|
|
61
|
+
expect(() => discoverSkills(dir)).toThrow(/must match its directory name/);
|
|
62
|
+
});
|
|
63
|
+
it("preserves arbitrary YAML frontmatter (arrays, nesting) verbatim", () => {
|
|
64
|
+
const dir = mkSkillDir({
|
|
65
|
+
"s/SKILL.md": "---\nname: s\ndescription: d\nallowed-tools:\n - get-order\n - refund\n---\n",
|
|
66
|
+
});
|
|
67
|
+
expect(discoverSkills(dir)[0]?.frontmatter["allowed-tools"]).toEqual([
|
|
68
|
+
"get-order",
|
|
69
|
+
"refund",
|
|
70
|
+
]);
|
|
71
|
+
});
|
|
72
|
+
it("throws on malformed YAML frontmatter", () => {
|
|
73
|
+
const dir = mkSkillDir({
|
|
74
|
+
"s/SKILL.md": "---\nname: 's\ndescription: [unclosed\n---\n",
|
|
75
|
+
});
|
|
76
|
+
expect(() => discoverSkills(dir)).toThrow(/Cannot parse frontmatter/);
|
|
77
|
+
});
|
|
78
|
+
});
|
|
79
|
+
describe("skillUriToRelPath", () => {
|
|
80
|
+
it("splits name and relative path", () => {
|
|
81
|
+
expect(skillUriToRelPath("skill://refunds/SKILL.md")).toEqual({
|
|
82
|
+
name: "refunds",
|
|
83
|
+
relPath: "SKILL.md",
|
|
84
|
+
});
|
|
85
|
+
expect(skillUriToRelPath("skill://refunds")).toEqual({
|
|
86
|
+
name: "refunds",
|
|
87
|
+
relPath: "",
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
it("rejects path traversal and malformed URIs", () => {
|
|
91
|
+
expect(() => skillUriToRelPath("skill://s/../../etc/passwd")).toThrow();
|
|
92
|
+
expect(() => skillUriToRelPath("skill://s/./x")).toThrow();
|
|
93
|
+
expect(() => skillUriToRelPath("https://example.com")).toThrow();
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
describe("registerSkills", () => {
|
|
97
|
+
const manifest = [
|
|
98
|
+
{
|
|
99
|
+
name: "refunds",
|
|
100
|
+
frontmatter: { name: "refunds", description: "Process refunds" },
|
|
101
|
+
digest: "sha256:abc",
|
|
102
|
+
files: {
|
|
103
|
+
"SKILL.md": "# Refunds",
|
|
104
|
+
"templates/email.md": "Hi",
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
];
|
|
108
|
+
function fakeRegistrar() {
|
|
109
|
+
const resources = new Map();
|
|
110
|
+
let dirHandler;
|
|
111
|
+
const server = {
|
|
112
|
+
registerResource: vi.fn((name, uri, _cfg, cb) => {
|
|
113
|
+
resources.set(name, {
|
|
114
|
+
uri,
|
|
115
|
+
cb: cb,
|
|
116
|
+
});
|
|
117
|
+
}),
|
|
118
|
+
server: {
|
|
119
|
+
setRequestHandler: vi.fn((_schema, handler) => {
|
|
120
|
+
dirHandler = handler;
|
|
121
|
+
}),
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
return { server, resources, getDirHandler: () => dirHandler };
|
|
125
|
+
}
|
|
126
|
+
it("builds an index.json with url, digest, and verbatim frontmatter", () => {
|
|
127
|
+
const { server, resources } = fakeRegistrar();
|
|
128
|
+
// biome-ignore lint/suspicious/noExplicitAny: structural test double
|
|
129
|
+
registerSkills(server, manifest);
|
|
130
|
+
const index = resources.get("skill-index");
|
|
131
|
+
const result = index?.cb(new URL(SKILL_INDEX_URI));
|
|
132
|
+
expect(JSON.parse(result.contents[0]?.text ?? "")).toEqual({
|
|
133
|
+
skills: [
|
|
134
|
+
{
|
|
135
|
+
url: "skill://refunds/SKILL.md",
|
|
136
|
+
digest: "sha256:abc",
|
|
137
|
+
frontmatter: { name: "refunds", description: "Process refunds" },
|
|
138
|
+
},
|
|
139
|
+
],
|
|
140
|
+
});
|
|
141
|
+
});
|
|
142
|
+
it("serves supporting files through the template resource", () => {
|
|
143
|
+
const { server, resources } = fakeRegistrar();
|
|
144
|
+
// biome-ignore lint/suspicious/noExplicitAny: structural test double
|
|
145
|
+
registerSkills(server, manifest);
|
|
146
|
+
const tpl = resources.get("skill-files");
|
|
147
|
+
expect(tpl?.uri).toBeInstanceOf(ResourceTemplate);
|
|
148
|
+
const url = new URL("skill://refunds/templates/email.md");
|
|
149
|
+
const result = tpl?.cb(url, {}, {});
|
|
150
|
+
expect(result.contents[0]?.text).toBe("Hi");
|
|
151
|
+
});
|
|
152
|
+
it("lists a subdirectory through the directory-read handler", () => {
|
|
153
|
+
const on = fakeRegistrar();
|
|
154
|
+
// biome-ignore lint/suspicious/noExplicitAny: structural test double
|
|
155
|
+
registerSkills(on.server, manifest);
|
|
156
|
+
const result = on.getDirHandler()?.({
|
|
157
|
+
params: { uri: "skill://refunds/templates" },
|
|
158
|
+
});
|
|
159
|
+
expect(result.resources).toEqual([
|
|
160
|
+
{
|
|
161
|
+
uri: "skill://refunds/templates/email.md",
|
|
162
|
+
name: "email.md",
|
|
163
|
+
mimeType: "text/markdown",
|
|
164
|
+
},
|
|
165
|
+
]);
|
|
166
|
+
});
|
|
167
|
+
it("lists a skill root and marks subdirectories as inode/directory", () => {
|
|
168
|
+
const { server, getDirHandler } = fakeRegistrar();
|
|
169
|
+
// biome-ignore lint/suspicious/noExplicitAny: structural test double
|
|
170
|
+
registerSkills(server, manifest);
|
|
171
|
+
const result = getDirHandler()?.({
|
|
172
|
+
params: { uri: "skill://refunds" },
|
|
173
|
+
});
|
|
174
|
+
expect(result.resources).toContainEqual({
|
|
175
|
+
uri: "skill://refunds/templates",
|
|
176
|
+
name: "templates",
|
|
177
|
+
mimeType: "inode/directory",
|
|
178
|
+
});
|
|
179
|
+
expect(result.resources).toContainEqual({
|
|
180
|
+
uri: "skill://refunds/SKILL.md",
|
|
181
|
+
name: "SKILL.md",
|
|
182
|
+
mimeType: "text/markdown",
|
|
183
|
+
});
|
|
184
|
+
});
|
|
185
|
+
});
|
|
186
|
+
describe("discoverSkills symlink safety", () => {
|
|
187
|
+
it("excludes symlinked files and directories from the manifest", () => {
|
|
188
|
+
const outside = mkdtempSync(join(tmpdir(), "skybridge-outside-"));
|
|
189
|
+
writeFileSync(join(outside, "secret.md"), "TOP SECRET");
|
|
190
|
+
const dir = mkSkillDir({
|
|
191
|
+
"demo/SKILL.md": FM("demo", "d"),
|
|
192
|
+
"demo/real.md": "ok",
|
|
193
|
+
});
|
|
194
|
+
symlinkSync(join(outside, "secret.md"), join(dir, "demo", "leak.md"));
|
|
195
|
+
symlinkSync(outside, join(dir, "demo", "escape"));
|
|
196
|
+
const files = discoverSkills(dir)[0]?.files ?? {};
|
|
197
|
+
expect(Object.keys(files).sort()).toEqual(["SKILL.md", "real.md"]);
|
|
198
|
+
});
|
|
199
|
+
it("ignores non-markdown supporting files", () => {
|
|
200
|
+
const dir = mkSkillDir({
|
|
201
|
+
"demo/SKILL.md": FM("demo", "d"),
|
|
202
|
+
"demo/notes.md": "kept",
|
|
203
|
+
"demo/data.json": "{}",
|
|
204
|
+
"demo/scripts/run.py": "print(1)",
|
|
205
|
+
});
|
|
206
|
+
const files = discoverSkills(dir)[0]?.files ?? {};
|
|
207
|
+
expect(Object.keys(files).sort()).toEqual(["SKILL.md", "notes.md"]);
|
|
208
|
+
});
|
|
209
|
+
});
|
|
210
|
+
//# sourceMappingURL=skills.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"skills.test.js","sourceRoot":"","sources":["../../src/server/skills.test.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAC7E,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yCAAyC,CAAC;AAC3E,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD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U,CAAC;YACrB,eAAe,EAAE,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC;YAChC,eAAe,EAAE,MAAM;YACvB,gBAAgB,EAAE,IAAI;YACtB,qBAAqB,EAAE,UAAU;SAClC,CAAC,CAAC;QACH,MAAM,KAAK,GAAG,cAAc,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,KAAK,IAAI,EAAE,CAAC;QAClD,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC;IACtE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["// @vitest-environment node\nimport { mkdirSync, mkdtempSync, symlinkSync, writeFileSync } from \"node:fs\";\nimport { tmpdir } from \"node:os\";\nimport { join } from \"node:path\";\nimport { ResourceTemplate } from \"@modelcontextprotocol/sdk/server/mcp.js\";\nimport { describe, expect, it, vi } from \"vitest\";\nimport {\n discoverSkills,\n registerSkills,\n SKILL_INDEX_URI,\n type Skill,\n skillUriToRelPath,\n} from \"./skills.js\";\n\nfunction mkSkillDir(files: Record<string, string>): string {\n const root = mkdtempSync(join(tmpdir(), \"skybridge-skills-\"));\n for (const [rel, content] of Object.entries(files)) {\n const full = join(root, rel);\n mkdirSync(join(full, \"..\"), { recursive: true });\n writeFileSync(full, content);\n }\n return root;\n}\n\nconst FM = (name: string, description: string) =>\n `---\\nname: ${name}\\ndescription: ${description}\\n---\\n`;\n\ndescribe(\"discoverSkills\", () => {\n it(\"discovers a skill with frontmatter, digest, and supporting files\", () => {\n const dir = mkSkillDir({\n \"git-workflow/SKILL.md\": `${FM(\"git-workflow\", \"Team git conventions\")}Body`,\n \"git-workflow/references/GUIDE.md\": \"# Guide\",\n });\n const [skill, ...rest] = discoverSkills(dir);\n expect(rest).toHaveLength(0);\n expect(skill?.name).toBe(\"git-workflow\");\n expect(skill?.frontmatter).toMatchObject({\n name: \"git-workflow\",\n description: \"Team git conventions\",\n });\n expect(skill?.digest).toMatch(/^sha256:[a-f0-9]{64}$/);\n expect(Object.keys(skill?.files ?? {}).sort()).toEqual([\n \"SKILL.md\",\n \"references/GUIDE.md\",\n ]);\n });\n\n it(\"returns [] for a missing directory and skips dirs without SKILL.md\", () => {\n expect(discoverSkills(join(tmpdir(), \"does-not-exist-xyz\"))).toEqual([]);\n const dir = mkSkillDir({ \"not-a-skill/README.md\": \"hi\" });\n expect(discoverSkills(dir)).toEqual([]);\n });\n\n it(\"parses a nested metadata map in frontmatter\", () => {\n const dir = mkSkillDir({\n \"s/SKILL.md\": `---\\nname: s\\ndescription: d\\nmetadata:\\n version: \"1.2\"\\n team: core\\n---\\n`,\n });\n expect(discoverSkills(dir)[0]?.frontmatter.metadata).toEqual({\n version: \"1.2\",\n team: \"core\",\n });\n });\n\n it(\"throws on missing frontmatter\", () => {\n const dir = mkSkillDir({ \"s/SKILL.md\": \"no frontmatter here\" });\n expect(() => discoverSkills(dir)).toThrow(/missing YAML frontmatter/);\n });\n\n it(\"throws when required fields are absent\", () => {\n const dir = mkSkillDir({ \"s/SKILL.md\": \"---\\nname: s\\n---\\n\" });\n expect(() => discoverSkills(dir)).toThrow(/Invalid skill frontmatter/);\n });\n\n it(\"throws when the frontmatter name does not match the directory\", () => {\n const dir = mkSkillDir({ \"s/SKILL.md\": FM(\"other\", \"d\") });\n expect(() => discoverSkills(dir)).toThrow(/must match its directory name/);\n });\n\n it(\"preserves arbitrary YAML frontmatter (arrays, nesting) verbatim\", () => {\n const dir = mkSkillDir({\n \"s/SKILL.md\":\n \"---\\nname: s\\ndescription: d\\nallowed-tools:\\n - get-order\\n - refund\\n---\\n\",\n });\n expect(discoverSkills(dir)[0]?.frontmatter[\"allowed-tools\"]).toEqual([\n \"get-order\",\n \"refund\",\n ]);\n });\n\n it(\"throws on malformed YAML frontmatter\", () => {\n const dir = mkSkillDir({\n \"s/SKILL.md\": \"---\\nname: 's\\ndescription: [unclosed\\n---\\n\",\n });\n expect(() => discoverSkills(dir)).toThrow(/Cannot parse frontmatter/);\n });\n});\n\ndescribe(\"skillUriToRelPath\", () => {\n it(\"splits name and relative path\", () => {\n expect(skillUriToRelPath(\"skill://refunds/SKILL.md\")).toEqual({\n name: \"refunds\",\n relPath: \"SKILL.md\",\n });\n expect(skillUriToRelPath(\"skill://refunds\")).toEqual({\n name: \"refunds\",\n relPath: \"\",\n });\n });\n\n it(\"rejects path traversal and malformed URIs\", () => {\n expect(() => skillUriToRelPath(\"skill://s/../../etc/passwd\")).toThrow();\n expect(() => skillUriToRelPath(\"skill://s/./x\")).toThrow();\n expect(() => skillUriToRelPath(\"https://example.com\")).toThrow();\n });\n});\n\ndescribe(\"registerSkills\", () => {\n const manifest: Skill[] = [\n {\n name: \"refunds\",\n frontmatter: { name: \"refunds\", description: \"Process refunds\" },\n digest: \"sha256:abc\",\n files: {\n \"SKILL.md\": \"# Refunds\",\n \"templates/email.md\": \"Hi\",\n },\n },\n ];\n\n function fakeRegistrar() {\n const resources = new Map<\n string,\n { uri: unknown; cb: (...args: unknown[]) => unknown }\n >();\n let dirHandler: ((req: unknown) => unknown) | undefined;\n const server = {\n registerResource: vi.fn(\n (name: string, uri: unknown, _cfg: unknown, cb: unknown) => {\n resources.set(name, {\n uri,\n cb: cb as (...args: unknown[]) => unknown,\n });\n },\n ),\n server: {\n setRequestHandler: vi.fn((_schema: unknown, handler: unknown) => {\n dirHandler = handler as (req: unknown) => unknown;\n }),\n },\n };\n return { server, resources, getDirHandler: () => dirHandler };\n }\n\n it(\"builds an index.json with url, digest, and verbatim frontmatter\", () => {\n const { server, resources } = fakeRegistrar();\n // biome-ignore lint/suspicious/noExplicitAny: structural test double\n registerSkills(server as any, manifest);\n const index = resources.get(\"skill-index\");\n const result = index?.cb(new URL(SKILL_INDEX_URI)) as {\n contents: { text: string }[];\n };\n expect(JSON.parse(result.contents[0]?.text ?? \"\")).toEqual({\n skills: [\n {\n url: \"skill://refunds/SKILL.md\",\n digest: \"sha256:abc\",\n frontmatter: { name: \"refunds\", description: \"Process refunds\" },\n },\n ],\n });\n });\n\n it(\"serves supporting files through the template resource\", () => {\n const { server, resources } = fakeRegistrar();\n // biome-ignore lint/suspicious/noExplicitAny: structural test double\n registerSkills(server as any, manifest);\n const tpl = resources.get(\"skill-files\");\n expect(tpl?.uri).toBeInstanceOf(ResourceTemplate);\n const url = new URL(\"skill://refunds/templates/email.md\");\n const result = tpl?.cb(url, {}, {}) as { contents: { text: string }[] };\n expect(result.contents[0]?.text).toBe(\"Hi\");\n });\n\n it(\"lists a subdirectory through the directory-read handler\", () => {\n const on = fakeRegistrar();\n // biome-ignore lint/suspicious/noExplicitAny: structural test double\n registerSkills(on.server as any, manifest);\n const result = on.getDirHandler()?.({\n params: { uri: \"skill://refunds/templates\" },\n }) as { resources: { uri: string; name: string; mimeType: string }[] };\n expect(result.resources).toEqual([\n {\n uri: \"skill://refunds/templates/email.md\",\n name: \"email.md\",\n mimeType: \"text/markdown\",\n },\n ]);\n });\n\n it(\"lists a skill root and marks subdirectories as inode/directory\", () => {\n const { server, getDirHandler } = fakeRegistrar();\n // biome-ignore lint/suspicious/noExplicitAny: structural test double\n registerSkills(server as any, manifest);\n const result = getDirHandler()?.({\n params: { uri: \"skill://refunds\" },\n }) as { resources: { name: string; mimeType: string }[] };\n expect(result.resources).toContainEqual({\n uri: \"skill://refunds/templates\",\n name: \"templates\",\n mimeType: \"inode/directory\",\n });\n expect(result.resources).toContainEqual({\n uri: \"skill://refunds/SKILL.md\",\n name: \"SKILL.md\",\n mimeType: \"text/markdown\",\n });\n });\n});\n\ndescribe(\"discoverSkills symlink safety\", () => {\n it(\"excludes symlinked files and directories from the manifest\", () => {\n const outside = mkdtempSync(join(tmpdir(), \"skybridge-outside-\"));\n writeFileSync(join(outside, \"secret.md\"), \"TOP SECRET\");\n const dir = mkSkillDir({\n \"demo/SKILL.md\": FM(\"demo\", \"d\"),\n \"demo/real.md\": \"ok\",\n });\n symlinkSync(join(outside, \"secret.md\"), join(dir, \"demo\", \"leak.md\"));\n symlinkSync(outside, join(dir, \"demo\", \"escape\"));\n\n const files = discoverSkills(dir)[0]?.files ?? {};\n expect(Object.keys(files).sort()).toEqual([\"SKILL.md\", \"real.md\"]);\n });\n\n it(\"ignores non-markdown supporting files\", () => {\n const dir = mkSkillDir({\n \"demo/SKILL.md\": FM(\"demo\", \"d\"),\n \"demo/notes.md\": \"kept\",\n \"demo/data.json\": \"{}\",\n \"demo/scripts/run.py\": \"print(1)\",\n });\n const files = discoverSkills(dir)[0]?.files ?? {};\n expect(Object.keys(files).sort()).toEqual([\"SKILL.md\", \"notes.md\"]);\n });\n});\n"]}
|
|
@@ -1,17 +1,15 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { ViewHostType } from "./server.js";
|
|
2
2
|
declare class TemplateHelper {
|
|
3
|
-
private templateCache;
|
|
4
|
-
private loadTemplate;
|
|
5
3
|
renderProduction(data: {
|
|
6
|
-
hostType:
|
|
4
|
+
hostType: ViewHostType;
|
|
7
5
|
serverUrl: string;
|
|
8
|
-
|
|
6
|
+
viewFile: string;
|
|
9
7
|
styleFile: string;
|
|
10
8
|
}): string;
|
|
11
9
|
renderDevelopment(data: {
|
|
12
|
-
hostType:
|
|
10
|
+
hostType: ViewHostType;
|
|
13
11
|
serverUrl: string;
|
|
14
|
-
|
|
12
|
+
viewName: string;
|
|
15
13
|
}): string;
|
|
16
14
|
}
|
|
17
15
|
export declare const templateHelper: TemplateHelper;
|
|
@@ -1,29 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { dirname, join } from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
|
-
import Handlebars from "handlebars";
|
|
5
|
-
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
-
const __dirname = dirname(__filename);
|
|
1
|
+
import { developmentTemplate, productionTemplate, } from "./templates.generated.js";
|
|
7
2
|
class TemplateHelper {
|
|
8
|
-
templateCache = new Map();
|
|
9
|
-
loadTemplate(templateName) {
|
|
10
|
-
const cached = this.templateCache.get(templateName);
|
|
11
|
-
if (cached) {
|
|
12
|
-
return cached;
|
|
13
|
-
}
|
|
14
|
-
const templatePath = join(__dirname, "templates", `${templateName}.hbs`);
|
|
15
|
-
const templateSource = readFileSync(templatePath, "utf-8");
|
|
16
|
-
const template = Handlebars.compile(templateSource);
|
|
17
|
-
this.templateCache.set(templateName, template);
|
|
18
|
-
return template;
|
|
19
|
-
}
|
|
20
3
|
renderProduction(data) {
|
|
21
|
-
|
|
22
|
-
return template(data);
|
|
4
|
+
return productionTemplate(data);
|
|
23
5
|
}
|
|
24
6
|
renderDevelopment(data) {
|
|
25
|
-
|
|
26
|
-
return template(data);
|
|
7
|
+
return developmentTemplate(data);
|
|
27
8
|
}
|
|
28
9
|
}
|
|
29
10
|
export const templateHelper = new TemplateHelper();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templateHelper.js","sourceRoot":"","sources":["../../src/server/templateHelper.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"templateHelper.js","sourceRoot":"","sources":["../../src/server/templateHelper.ts"],"names":[],"mappings":"AACA,OAAO,EACL,mBAAmB,EACnB,kBAAkB,GACnB,MAAM,0BAA0B,CAAC;AAElC,MAAM,cAAc;IAClB,gBAAgB,CAAC,IAKhB;QACC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC;IAClC,CAAC;IAED,iBAAiB,CAAC,IAIjB;QACC,OAAO,mBAAmB,CAAC,IAAI,CAAC,CAAC;IACnC,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC","sourcesContent":["import type { ViewHostType } from \"./server.js\";\nimport {\n developmentTemplate,\n productionTemplate,\n} from \"./templates.generated.js\";\n\nclass TemplateHelper {\n renderProduction(data: {\n hostType: ViewHostType;\n serverUrl: string;\n viewFile: string;\n styleFile: string;\n }): string {\n return productionTemplate(data);\n }\n\n renderDevelopment(data: {\n hostType: ViewHostType;\n serverUrl: string;\n viewName: string;\n }): string {\n return developmentTemplate(data);\n }\n}\n\nexport const templateHelper = new TemplateHelper();\n"]}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// AUTO-GENERATED by scripts/precompile-templates.mjs. Do not edit.
|
|
2
|
+
import Handlebars from "handlebars/runtime.js";
|
|
3
|
+
/** @type {HandlebarsTemplateDelegate} */
|
|
4
|
+
export const developmentTemplate = Handlebars.template({ "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
|
|
5
|
+
var helper, alias1 = depth0 != null ? depth0 : (container.nullContext || {}), alias2 = container.hooks.helperMissing, alias3 = "function", alias4 = container.escapeExpression, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
6
|
+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
|
7
|
+
return parent[propertyName];
|
|
8
|
+
}
|
|
9
|
+
return undefined;
|
|
10
|
+
};
|
|
11
|
+
return "<script type=\"module\">window.skybridge = { hostType: \""
|
|
12
|
+
+ alias4(((helper = (helper = lookupProperty(helpers, "hostType") || (depth0 != null ? lookupProperty(depth0, "hostType") : depth0)) != null ? helper : alias2), (typeof helper === alias3 ? helper.call(alias1, { "name": "hostType", "hash": {}, "data": data, "loc": { "start": { "line": 1, "column": 54 }, "end": { "line": 1, "column": 66 } } }) : helper)))
|
|
13
|
+
+ "\", serverUrl: \""
|
|
14
|
+
+ alias4(((helper = (helper = lookupProperty(helpers, "serverUrl") || (depth0 != null ? lookupProperty(depth0, "serverUrl") : depth0)) != null ? helper : alias2), (typeof helper === alias3 ? helper.call(alias1, { "name": "serverUrl", "hash": {}, "data": data, "loc": { "start": { "line": 1, "column": 81 }, "end": { "line": 1, "column": 94 } } }) : helper)))
|
|
15
|
+
+ "\" };</script>\n<script type=\"module\">\n import { injectIntoGlobalHook } from \""
|
|
16
|
+
+ alias4(((helper = (helper = lookupProperty(helpers, "serverUrl") || (depth0 != null ? lookupProperty(depth0, "serverUrl") : depth0)) != null ? helper : alias2), (typeof helper === alias3 ? helper.call(alias1, { "name": "serverUrl", "hash": {}, "data": data, "loc": { "start": { "line": 3, "column": 40 }, "end": { "line": 3, "column": 53 } } }) : helper)))
|
|
17
|
+
+ "/assets/@react-refresh\";\n injectIntoGlobalHook(window); window.$RefreshReg$ = () => {};\n window.$RefreshSig$ = () => (type) => type;\n window.__vite_plugin_react_preamble_installed__ = true;\n</script>\n<script type=\"module\" src=\""
|
|
18
|
+
+ alias4(((helper = (helper = lookupProperty(helpers, "serverUrl") || (depth0 != null ? lookupProperty(depth0, "serverUrl") : depth0)) != null ? helper : alias2), (typeof helper === alias3 ? helper.call(alias1, { "name": "serverUrl", "hash": {}, "data": data, "loc": { "start": { "line": 8, "column": 27 }, "end": { "line": 8, "column": 40 } } }) : helper)))
|
|
19
|
+
+ "/@vite/client\"></script>\n<div id=\"root\"></div>\n<script type=\"module\" id=\"dev-view-entry\">\n import('"
|
|
20
|
+
+ alias4(((helper = (helper = lookupProperty(helpers, "serverUrl") || (depth0 != null ? lookupProperty(depth0, "serverUrl") : depth0)) != null ? helper : alias2), (typeof helper === alias3 ? helper.call(alias1, { "name": "serverUrl", "hash": {}, "data": data, "loc": { "start": { "line": 11, "column": 10 }, "end": { "line": 11, "column": 23 } } }) : helper)))
|
|
21
|
+
+ "/_skybridge/view/"
|
|
22
|
+
+ alias4(((helper = (helper = lookupProperty(helpers, "viewName") || (depth0 != null ? lookupProperty(depth0, "viewName") : depth0)) != null ? helper : alias2), (typeof helper === alias3 ? helper.call(alias1, { "name": "viewName", "hash": {}, "data": data, "loc": { "start": { "line": 11, "column": 40 }, "end": { "line": 11, "column": 52 } } }) : helper)))
|
|
23
|
+
+ "');\n</script>";
|
|
24
|
+
}, "useData": true });
|
|
25
|
+
/** @type {HandlebarsTemplateDelegate} */
|
|
26
|
+
export const productionTemplate = Handlebars.template({ "compiler": [8, ">= 4.3.0"], "main": function (container, depth0, helpers, partials, data) {
|
|
27
|
+
var helper, alias1 = depth0 != null ? depth0 : (container.nullContext || {}), alias2 = container.hooks.helperMissing, alias3 = "function", alias4 = container.escapeExpression, lookupProperty = container.lookupProperty || function (parent, propertyName) {
|
|
28
|
+
if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {
|
|
29
|
+
return parent[propertyName];
|
|
30
|
+
}
|
|
31
|
+
return undefined;
|
|
32
|
+
};
|
|
33
|
+
return "<script type=\"module\">window.skybridge = { hostType: \""
|
|
34
|
+
+ alias4(((helper = (helper = lookupProperty(helpers, "hostType") || (depth0 != null ? lookupProperty(depth0, "hostType") : depth0)) != null ? helper : alias2), (typeof helper === alias3 ? helper.call(alias1, { "name": "hostType", "hash": {}, "data": data, "loc": { "start": { "line": 1, "column": 54 }, "end": { "line": 1, "column": 66 } } }) : helper)))
|
|
35
|
+
+ "\", serverUrl: \""
|
|
36
|
+
+ alias4(((helper = (helper = lookupProperty(helpers, "serverUrl") || (depth0 != null ? lookupProperty(depth0, "serverUrl") : depth0)) != null ? helper : alias2), (typeof helper === alias3 ? helper.call(alias1, { "name": "serverUrl", "hash": {}, "data": data, "loc": { "start": { "line": 1, "column": 81 }, "end": { "line": 1, "column": 94 } } }) : helper)))
|
|
37
|
+
+ "\" };</script>\n<div id=\"root\"></div>\n<script type=\"module\">\n import('"
|
|
38
|
+
+ alias4(((helper = (helper = lookupProperty(helpers, "serverUrl") || (depth0 != null ? lookupProperty(depth0, "serverUrl") : depth0)) != null ? helper : alias2), (typeof helper === alias3 ? helper.call(alias1, { "name": "serverUrl", "hash": {}, "data": data, "loc": { "start": { "line": 4, "column": 10 }, "end": { "line": 4, "column": 23 } } }) : helper)))
|
|
39
|
+
+ "/assets/"
|
|
40
|
+
+ alias4(((helper = (helper = lookupProperty(helpers, "viewFile") || (depth0 != null ? lookupProperty(depth0, "viewFile") : depth0)) != null ? helper : alias2), (typeof helper === alias3 ? helper.call(alias1, { "name": "viewFile", "hash": {}, "data": data, "loc": { "start": { "line": 4, "column": 31 }, "end": { "line": 4, "column": 43 } } }) : helper)))
|
|
41
|
+
+ "');\n</script>\n<link rel=\"stylesheet\" crossorigin href=\""
|
|
42
|
+
+ alias4(((helper = (helper = lookupProperty(helpers, "serverUrl") || (depth0 != null ? lookupProperty(depth0, "serverUrl") : depth0)) != null ? helper : alias2), (typeof helper === alias3 ? helper.call(alias1, { "name": "serverUrl", "hash": {}, "data": data, "loc": { "start": { "line": 6, "column": 41 }, "end": { "line": 6, "column": 54 } } }) : helper)))
|
|
43
|
+
+ "/assets/"
|
|
44
|
+
+ alias4(((helper = (helper = lookupProperty(helpers, "styleFile") || (depth0 != null ? lookupProperty(depth0, "styleFile") : depth0)) != null ? helper : alias2), (typeof helper === alias3 ? helper.call(alias1, { "name": "styleFile", "hash": {}, "data": data, "loc": { "start": { "line": 6, "column": 62 }, "end": { "line": 6, "column": 75 } } }) : helper)))
|
|
45
|
+
+ "\" />";
|
|
46
|
+
}, "useData": true });
|
|
47
|
+
//# sourceMappingURL=templates.generated.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.generated.js","sourceRoot":"","sources":["../../src/server/templates.generated.js"],"names":[],"mappings":"AAAA,mEAAmE;AACnE,OAAO,UAAU,MAAM,uBAAuB,CAAC;AAE/C,yCAAyC;AACzC,MAAM,CAAC,MAAM,mBAAmB,GAAG,UAAU,CAAC,QAAQ,CAAC,EAAC,UAAU,EAAC,CAAC,CAAC,EAAC,UAAU,CAAC,EAAC,MAAM,EAAC,UAAS,SAAS,EAAC,MAAM,EAAC,OAAO,EAAC,QAAQ,EAAC,IAAI;QACpI,IAAI,MAAM,EAAE,MAAM,GAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,WAAW,IAAI,EAAE,CAAC,EAAE,MAAM,GAAC,SAAS,CAAC,KAAK,CAAC,aAAa,EAAE,MAAM,GAAC,UAAU,EAAE,MAAM,GAAC,SAAS,CAAC,gBAAgB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,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,MAAM,GAAG,cAAc,CAAC,OAAO,EAAC,WAAW,CAAC,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,CAAC,CAAC,cAAc,CAAC,MAAM,EAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,EAAC,CAAC,OAAO,MAAM,KAAK,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAC,EAAC,MAAM,EAAC,WAAW,EAAC,MAAM,EAAC,EAAE,EAAC,MAAM,EAAC,IAAI,EAAC,KAAK,EAAC,EAAC,OAAO,EAAC,EAAC,MAAM,EAAC,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAC,EAAC,KAAK,EAAC,EAAC,MAAM,EAAC,CAAC,EAAC,QAAQ,EAAC,EAAE,EAAC,EAAC,EAAC,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;cACxU,OAAO,CAAC;IACd,CAAC,EAAC,SAAS,EAAC,IAAI,EAAC,CAAC,CAAC","sourcesContent":["// AUTO-GENERATED by scripts/precompile-templates.mjs. Do not edit.\nimport Handlebars from \"handlebars/runtime.js\";\n\n/** @type {HandlebarsTemplateDelegate} */\nexport const developmentTemplate = Handlebars.template({\"compiler\":[8,\">= 4.3.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3=\"function\", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return \"<script type=\\\"module\\\">window.skybridge = { hostType: \\\"\"\n + alias4(((helper = (helper = lookupProperty(helpers,\"hostType\") || (depth0 != null ? lookupProperty(depth0,\"hostType\") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"hostType\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":54},\"end\":{\"line\":1,\"column\":66}}}) : helper)))\n + \"\\\", serverUrl: \\\"\"\n + alias4(((helper = (helper = lookupProperty(helpers,\"serverUrl\") || (depth0 != null ? lookupProperty(depth0,\"serverUrl\") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"serverUrl\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":81},\"end\":{\"line\":1,\"column\":94}}}) : helper)))\n + \"\\\" };</script>\\n<script type=\\\"module\\\">\\n import { injectIntoGlobalHook } from \\\"\"\n + alias4(((helper = (helper = lookupProperty(helpers,\"serverUrl\") || (depth0 != null ? lookupProperty(depth0,\"serverUrl\") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"serverUrl\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":3,\"column\":40},\"end\":{\"line\":3,\"column\":53}}}) : helper)))\n + \"/assets/@react-refresh\\\";\\n injectIntoGlobalHook(window); window.$RefreshReg$ = () => {};\\n window.$RefreshSig$ = () => (type) => type;\\n window.__vite_plugin_react_preamble_installed__ = true;\\n</script>\\n<script type=\\\"module\\\" src=\\\"\"\n + alias4(((helper = (helper = lookupProperty(helpers,\"serverUrl\") || (depth0 != null ? lookupProperty(depth0,\"serverUrl\") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"serverUrl\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":8,\"column\":27},\"end\":{\"line\":8,\"column\":40}}}) : helper)))\n + \"/@vite/client\\\"></script>\\n<div id=\\\"root\\\"></div>\\n<script type=\\\"module\\\" id=\\\"dev-view-entry\\\">\\n import('\"\n + alias4(((helper = (helper = lookupProperty(helpers,\"serverUrl\") || (depth0 != null ? lookupProperty(depth0,\"serverUrl\") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"serverUrl\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":11,\"column\":10},\"end\":{\"line\":11,\"column\":23}}}) : helper)))\n + \"/_skybridge/view/\"\n + alias4(((helper = (helper = lookupProperty(helpers,\"viewName\") || (depth0 != null ? lookupProperty(depth0,\"viewName\") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"viewName\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":11,\"column\":40},\"end\":{\"line\":11,\"column\":52}}}) : helper)))\n + \"');\\n</script>\";\n},\"useData\":true});\n/** @type {HandlebarsTemplateDelegate} */\nexport const productionTemplate = Handlebars.template({\"compiler\":[8,\">= 4.3.0\"],\"main\":function(container,depth0,helpers,partials,data) {\n var helper, alias1=depth0 != null ? depth0 : (container.nullContext || {}), alias2=container.hooks.helperMissing, alias3=\"function\", alias4=container.escapeExpression, lookupProperty = container.lookupProperty || function(parent, propertyName) {\n if (Object.prototype.hasOwnProperty.call(parent, propertyName)) {\n return parent[propertyName];\n }\n return undefined\n };\n\n return \"<script type=\\\"module\\\">window.skybridge = { hostType: \\\"\"\n + alias4(((helper = (helper = lookupProperty(helpers,\"hostType\") || (depth0 != null ? lookupProperty(depth0,\"hostType\") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"hostType\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":54},\"end\":{\"line\":1,\"column\":66}}}) : helper)))\n + \"\\\", serverUrl: \\\"\"\n + alias4(((helper = (helper = lookupProperty(helpers,\"serverUrl\") || (depth0 != null ? lookupProperty(depth0,\"serverUrl\") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"serverUrl\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":1,\"column\":81},\"end\":{\"line\":1,\"column\":94}}}) : helper)))\n + \"\\\" };</script>\\n<div id=\\\"root\\\"></div>\\n<script type=\\\"module\\\">\\n import('\"\n + alias4(((helper = (helper = lookupProperty(helpers,\"serverUrl\") || (depth0 != null ? lookupProperty(depth0,\"serverUrl\") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"serverUrl\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":4,\"column\":10},\"end\":{\"line\":4,\"column\":23}}}) : helper)))\n + \"/assets/\"\n + alias4(((helper = (helper = lookupProperty(helpers,\"viewFile\") || (depth0 != null ? lookupProperty(depth0,\"viewFile\") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"viewFile\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":4,\"column\":31},\"end\":{\"line\":4,\"column\":43}}}) : helper)))\n + \"');\\n</script>\\n<link rel=\\\"stylesheet\\\" crossorigin href=\\\"\"\n + alias4(((helper = (helper = lookupProperty(helpers,\"serverUrl\") || (depth0 != null ? lookupProperty(depth0,\"serverUrl\") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"serverUrl\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":6,\"column\":41},\"end\":{\"line\":6,\"column\":54}}}) : helper)))\n + \"/assets/\"\n + alias4(((helper = (helper = lookupProperty(helpers,\"styleFile\") || (depth0 != null ? lookupProperty(depth0,\"styleFile\") : depth0)) != null ? helper : alias2),(typeof helper === alias3 ? helper.call(alias1,{\"name\":\"styleFile\",\"hash\":{},\"data\":data,\"loc\":{\"start\":{\"line\":6,\"column\":62},\"end\":{\"line\":6,\"column\":75}}}) : helper)))\n + \"\\\" />\";\n},\"useData\":true});\n"]}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type Router } from "express";
|
|
2
|
+
/**
|
|
3
|
+
* Builds an Express router that forwards `/__skybridge/tunnel` (POST/DELETE)
|
|
4
|
+
* and `/__skybridge/tunnel/events` (GET, SSE) to the cli's loopback control
|
|
5
|
+
* server. The `/__skybridge/` prefix avoids colliding with user-defined routes.
|
|
6
|
+
*/
|
|
7
|
+
export declare function createTunnelProxyRouter(controlPort: number): Router;
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import express, {} from "express";
|
|
2
|
+
/**
|
|
3
|
+
* Builds an Express router that forwards `/__skybridge/tunnel` (POST/DELETE)
|
|
4
|
+
* and `/__skybridge/tunnel/events` (GET, SSE) to the cli's loopback control
|
|
5
|
+
* server. The `/__skybridge/` prefix avoids colliding with user-defined routes.
|
|
6
|
+
*/
|
|
7
|
+
export function createTunnelProxyRouter(controlPort) {
|
|
8
|
+
const router = express.Router();
|
|
9
|
+
const upstream = `http://127.0.0.1:${controlPort}/__skybridge/tunnel`;
|
|
10
|
+
const forwardJson = async (method, res) => {
|
|
11
|
+
try {
|
|
12
|
+
const upstreamRes = await fetch(upstream, { method });
|
|
13
|
+
const body = await upstreamRes.text();
|
|
14
|
+
res
|
|
15
|
+
.status(upstreamRes.status)
|
|
16
|
+
.type(upstreamRes.headers.get("content-type") ?? "application/json")
|
|
17
|
+
.send(body);
|
|
18
|
+
}
|
|
19
|
+
catch (err) {
|
|
20
|
+
res.status(502).json({
|
|
21
|
+
status: "error",
|
|
22
|
+
message: err instanceof Error ? err.message : "Tunnel control unavailable",
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
router.post("/__skybridge/tunnel", (_req, res) => {
|
|
27
|
+
void forwardJson("POST", res);
|
|
28
|
+
});
|
|
29
|
+
router.delete("/__skybridge/tunnel", (_req, res) => {
|
|
30
|
+
void forwardJson("DELETE", res);
|
|
31
|
+
});
|
|
32
|
+
router.get("/__skybridge/tunnel/events", async (req, res) => {
|
|
33
|
+
// Abort the upstream fetch when the client disconnects (or when the dev
|
|
34
|
+
// server shuts down and destroys the response).
|
|
35
|
+
const controller = new AbortController();
|
|
36
|
+
const onClose = () => controller.abort();
|
|
37
|
+
req.on("close", onClose);
|
|
38
|
+
let upstreamRes;
|
|
39
|
+
try {
|
|
40
|
+
upstreamRes = await fetch(`${upstream}/events`, {
|
|
41
|
+
signal: controller.signal,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
req.off("close", onClose);
|
|
46
|
+
if (!res.headersSent) {
|
|
47
|
+
res.status(502).json({
|
|
48
|
+
status: "error",
|
|
49
|
+
message: err instanceof Error ? err.message : "Tunnel control unavailable",
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const upstreamBody = upstreamRes.body;
|
|
55
|
+
if (!upstreamRes.ok || !upstreamBody) {
|
|
56
|
+
req.off("close", onClose);
|
|
57
|
+
res.status(upstreamRes.status).end();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
res.setHeader("Content-Type", upstreamRes.headers.get("content-type") ?? "text/event-stream");
|
|
61
|
+
res.setHeader("Cache-Control", "no-cache, no-transform");
|
|
62
|
+
res.setHeader("Connection", "keep-alive");
|
|
63
|
+
res.flushHeaders?.();
|
|
64
|
+
const reader = upstreamBody.getReader();
|
|
65
|
+
try {
|
|
66
|
+
while (true) {
|
|
67
|
+
const { value, done } = await reader.read();
|
|
68
|
+
if (done) {
|
|
69
|
+
break;
|
|
70
|
+
}
|
|
71
|
+
if (!res.write(value)) {
|
|
72
|
+
// Race "drain" against "close": Node does not emit "drain" on a
|
|
73
|
+
// destroyed socket, so without the close listener this hangs
|
|
74
|
+
// forever when the client disconnects under backpressure, leaking
|
|
75
|
+
// the upstream fetch and TunnelManager listeners.
|
|
76
|
+
await new Promise((resolve) => {
|
|
77
|
+
const onDrain = () => {
|
|
78
|
+
res.off("close", onClose);
|
|
79
|
+
resolve();
|
|
80
|
+
};
|
|
81
|
+
const onClose = () => {
|
|
82
|
+
res.off("drain", onDrain);
|
|
83
|
+
resolve();
|
|
84
|
+
};
|
|
85
|
+
res.once("drain", onDrain);
|
|
86
|
+
res.once("close", onClose);
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
catch {
|
|
92
|
+
// upstream aborted (typically because the client disconnected) —
|
|
93
|
+
// fall through to end()
|
|
94
|
+
}
|
|
95
|
+
finally {
|
|
96
|
+
req.off("close", onClose);
|
|
97
|
+
// Release the reader so the upstream stream's lifecycle isn't held by
|
|
98
|
+
// a lingering lock on the clean-done path.
|
|
99
|
+
try {
|
|
100
|
+
await reader.cancel();
|
|
101
|
+
}
|
|
102
|
+
catch {
|
|
103
|
+
// ignore — the reader may already be closed
|
|
104
|
+
}
|
|
105
|
+
res.end();
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
return router;
|
|
109
|
+
}
|
|
110
|
+
//# sourceMappingURL=tunnel-proxy-router.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tunnel-proxy-router.js","sourceRoot":"","sources":["../../src/server/tunnel-proxy-router.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAe,MAAM,SAAS,CAAC;AAE/C;;;;GAIG;AACH,MAAM,UAAU,uBAAuB,CAAC,WAAmB;IACzD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAChC,MAAM,QAAQ,GAAG,oBAAoB,WAAW,qBAAqB,CAAC;IAEtE,MAAM,WAAW,GAAG,KAAK,EACvB,MAAyB,EACzB,GAAqB,EACN,EAAE;QACjB,IAAI,CAAC;YACH,MAAM,WAAW,GAAG,MAAM,KAAK,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,CAAC,CAAC;YACtD,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,IAAI,EAAE,CAAC;YACtC,GAAG;iBACA,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC;iBAC1B,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,IAAI,kBAAkB,CAAC;iBACnE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AAO,GAAG,GAAG,EAAE;4BACnB,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;4BAC1B,OAAO,EAAE,CAAC;wBACZ,CAAC,CAAC;wBACF,MAAM,OAAO,GAAG,GAAG,EAAE;4BACnB,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;4BAC1B,OAAO,EAAE,CAAC;wBACZ,CAAC,CAAC;wBACF,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;wBAC3B,GAAG,CAAC,IAAI,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;oBAC7B,CAAC,CAAC,CAAC;gBACL,CAAC;YACH,CAAC;QACH,CAAC;QAAC,MAAM,CAAC;YACP,iEAAiE;YACjE,wBAAwB;QAC1B,CAAC;gBAAS,CAAC;YACT,GAAG,CAAC,GAAG,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;YAC1B,sEAAsE;YACtE,2CAA2C;YAC3C,IAAI,CAAC;gBACH,MAAM,MAAM,CAAC,MAAM,EAAE,CAAC;YACxB,CAAC;YAAC,MAAM,CAAC;gBACP,4CAA4C;YAC9C,CAAC;YACD,GAAG,CAAC,GAAG,EAAE,CAAC;QACZ,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import express, { type Router } from \"express\";\n\n/**\n * Builds an Express router that forwards `/__skybridge/tunnel` (POST/DELETE)\n * and `/__skybridge/tunnel/events` (GET, SSE) to the cli's loopback control\n * server. The `/__skybridge/` prefix avoids colliding with user-defined routes.\n */\nexport function createTunnelProxyRouter(controlPort: number): Router {\n const router = express.Router();\n const upstream = `http://127.0.0.1:${controlPort}/__skybridge/tunnel`;\n\n const forwardJson = async (\n method: \"POST\" | \"DELETE\",\n res: express.Response,\n ): Promise<void> => {\n try {\n const upstreamRes = await fetch(upstream, { method });\n const body = await upstreamRes.text();\n res\n .status(upstreamRes.status)\n .type(upstreamRes.headers.get(\"content-type\") ?? \"application/json\")\n .send(body);\n } catch (err) {\n res.status(502).json({\n status: \"error\",\n message:\n err instanceof Error ? err.message : \"Tunnel control unavailable\",\n });\n }\n };\n\n router.post(\"/__skybridge/tunnel\", (_req, res) => {\n void forwardJson(\"POST\", res);\n });\n\n router.delete(\"/__skybridge/tunnel\", (_req, res) => {\n void forwardJson(\"DELETE\", res);\n });\n\n router.get(\"/__skybridge/tunnel/events\", async (req, res) => {\n // Abort the upstream fetch when the client disconnects (or when the dev\n // server shuts down and destroys the response).\n const controller = new AbortController();\n const onClose = () => controller.abort();\n req.on(\"close\", onClose);\n\n let upstreamRes: Response;\n try {\n upstreamRes = await fetch(`${upstream}/events`, {\n signal: controller.signal,\n });\n } catch (err) {\n req.off(\"close\", onClose);\n if (!res.headersSent) {\n res.status(502).json({\n status: \"error\",\n message:\n err instanceof Error ? err.message : \"Tunnel control unavailable\",\n });\n }\n return;\n }\n\n const upstreamBody = upstreamRes.body;\n if (!upstreamRes.ok || !upstreamBody) {\n req.off(\"close\", onClose);\n res.status(upstreamRes.status).end();\n return;\n }\n\n res.setHeader(\n \"Content-Type\",\n upstreamRes.headers.get(\"content-type\") ?? \"text/event-stream\",\n );\n res.setHeader(\"Cache-Control\", \"no-cache, no-transform\");\n res.setHeader(\"Connection\", \"keep-alive\");\n res.flushHeaders?.();\n\n const reader = upstreamBody.getReader();\n try {\n while (true) {\n const { value, done } = await reader.read();\n if (done) {\n break;\n }\n if (!res.write(value)) {\n // Race \"drain\" against \"close\": Node does not emit \"drain\" on a\n // destroyed socket, so without the close listener this hangs\n // forever when the client disconnects under backpressure, leaking\n // the upstream fetch and TunnelManager listeners.\n await new Promise<void>((resolve) => {\n const onDrain = () => {\n res.off(\"close\", onClose);\n resolve();\n };\n const onClose = () => {\n res.off(\"drain\", onDrain);\n resolve();\n };\n res.once(\"drain\", onDrain);\n res.once(\"close\", onClose);\n });\n }\n }\n } catch {\n // upstream aborted (typically because the client disconnected) —\n // fall through to end()\n } finally {\n req.off(\"close\", onClose);\n // Release the reader so the upstream stream's lifecycle isn't held by\n // a lingering lock on the clean-done path.\n try {\n await reader.cancel();\n } catch {\n // ignore — the reader may already be closed\n }\n res.end();\n }\n });\n\n return router;\n}\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|