skybridge 0.0.0-dev.b7f7a70 → 0.0.0-dev.b807968
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 +60 -41
- package/dist/cli/build-helpers.d.ts +14 -0
- package/dist/cli/build-helpers.js +144 -0
- package/dist/cli/build-helpers.js.map +1 -0
- package/dist/cli/build-helpers.test.js +199 -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 +84 -0
- package/dist/cli/build-steps.js.map +1 -0
- package/dist/cli/build-steps.test.js +72 -0
- package/dist/cli/build-steps.test.js.map +1 -0
- package/dist/cli/detect-port.d.ts +2 -2
- package/dist/cli/detect-port.js +8 -20
- package/dist/cli/detect-port.js.map +1 -1
- package/dist/cli/header.d.ts +1 -1
- package/dist/cli/resolve-skybridge-config.d.ts +6 -0
- package/dist/cli/resolve-skybridge-config.js +28 -0
- package/dist/cli/resolve-skybridge-config.js.map +1 -0
- package/dist/cli/run-plain.d.ts +18 -0
- package/dist/cli/run-plain.js +90 -0
- package/dist/cli/run-plain.js.map +1 -0
- package/dist/cli/telemetry.js +2 -0
- package/dist/cli/telemetry.js.map +1 -1
- package/dist/cli/use-execute-steps.d.ts +1 -1
- package/dist/cli/use-nodemon.d.ts +25 -1
- package/dist/cli/use-nodemon.js +96 -63
- package/dist/cli/use-nodemon.js.map +1 -1
- package/dist/cli/use-typescript-check.d.ts +8 -2
- package/dist/cli/use-typescript-check.js +73 -68
- package/dist/cli/use-typescript-check.js.map +1 -1
- package/dist/commands/build.d.ts +0 -3
- package/dist/commands/build.js +2 -73
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/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 +1 -0
- package/dist/commands/dev.js +51 -3
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.js +7 -1
- package/dist/commands/start.js.map +1 -1
- package/dist/context-warnings.d.ts +5 -0
- package/dist/context-warnings.js +31 -0
- package/dist/context-warnings.js.map +1 -0
- package/dist/context-warnings.test.js +28 -0
- package/dist/context-warnings.test.js.map +1 -0
- package/dist/server/app.d.ts +211 -0
- package/dist/server/app.js +277 -0
- package/dist/server/app.js.map +1 -0
- package/dist/server/app.test.js +178 -0
- package/dist/server/app.test.js.map +1 -0
- package/dist/server/asset-base-url-transform-plugin.d.ts +1 -0
- package/dist/server/asset-base-url-transform-plugin.js +16 -1
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.test.js +51 -1
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
- package/dist/server/auth/discovery.d.ts +33 -0
- package/dist/server/auth/discovery.js +56 -0
- package/dist/server/auth/discovery.js.map +1 -0
- package/dist/server/auth/discovery.test.d.ts +1 -0
- package/dist/server/auth/discovery.test.js +93 -0
- package/dist/server/auth/discovery.test.js.map +1 -0
- package/dist/server/auth/index.d.ts +48 -0
- package/dist/server/auth/index.js +2 -0
- package/dist/server/auth/index.js.map +1 -0
- package/dist/server/auth/providers/auth0.d.ts +40 -0
- package/dist/server/auth/providers/auth0.js +36 -0
- package/dist/server/auth/providers/auth0.js.map +1 -0
- package/dist/server/auth/providers/auth0.test.d.ts +1 -0
- package/dist/server/auth/providers/auth0.test.js +50 -0
- package/dist/server/auth/providers/auth0.test.js.map +1 -0
- package/dist/server/auth/providers/authplane.d.ts +49 -0
- package/dist/server/auth/providers/authplane.js +57 -0
- package/dist/server/auth/providers/authplane.js.map +1 -0
- package/dist/server/auth/providers/authplane.test.d.ts +1 -0
- package/dist/server/auth/providers/authplane.test.js +143 -0
- package/dist/server/auth/providers/authplane.test.js.map +1 -0
- package/dist/server/auth/providers/clerk.d.ts +51 -0
- package/dist/server/auth/providers/clerk.js +19 -0
- package/dist/server/auth/providers/clerk.js.map +1 -0
- package/dist/server/auth/providers/clerk.test.d.ts +1 -0
- package/dist/server/auth/providers/clerk.test.js +30 -0
- package/dist/server/auth/providers/clerk.test.js.map +1 -0
- package/dist/server/auth/providers/custom.d.ts +42 -0
- package/dist/server/auth/providers/custom.js +59 -0
- package/dist/server/auth/providers/custom.js.map +1 -0
- package/dist/server/auth/providers/custom.test.d.ts +1 -0
- package/dist/server/auth/providers/custom.test.js +161 -0
- package/dist/server/auth/providers/custom.test.js.map +1 -0
- package/dist/server/auth/providers/descope.d.ts +44 -0
- package/dist/server/auth/providers/descope.js +44 -0
- package/dist/server/auth/providers/descope.js.map +1 -0
- package/dist/server/auth/providers/descope.test.d.ts +1 -0
- package/dist/server/auth/providers/descope.test.js +62 -0
- package/dist/server/auth/providers/descope.test.js.map +1 -0
- package/dist/server/auth/providers/shared.d.ts +2 -0
- package/dist/server/auth/providers/shared.js +6 -0
- package/dist/server/auth/providers/shared.js.map +1 -0
- package/dist/server/auth/providers/shared.test.d.ts +1 -0
- package/dist/server/auth/providers/shared.test.js +10 -0
- package/dist/server/auth/providers/shared.test.js.map +1 -0
- package/dist/server/auth/providers/stytch.d.ts +25 -0
- package/dist/server/auth/providers/stytch.js +16 -0
- package/dist/server/auth/providers/stytch.js.map +1 -0
- package/dist/server/auth/providers/verify-spy.d.ts +12 -0
- package/dist/server/auth/providers/verify-spy.js +21 -0
- package/dist/server/auth/providers/verify-spy.js.map +1 -0
- package/dist/server/auth/providers/workos.d.ts +34 -0
- package/dist/server/auth/providers/workos.js +16 -0
- package/dist/server/auth/providers/workos.js.map +1 -0
- package/dist/server/auth/security-schemes.d.ts +23 -0
- package/dist/server/auth/security-schemes.js +64 -0
- package/dist/server/auth/security-schemes.js.map +1 -0
- package/dist/server/auth/security-schemes.test.d.ts +1 -0
- package/dist/server/auth/security-schemes.test.js +99 -0
- package/dist/server/auth/security-schemes.test.js.map +1 -0
- package/dist/server/auth/setup.d.ts +6 -0
- package/dist/server/auth/setup.js +91 -0
- package/dist/server/auth/setup.js.map +1 -0
- package/dist/server/auth/setup.test.d.ts +1 -0
- package/dist/server/auth/setup.test.js +514 -0
- package/dist/server/auth/setup.test.js.map +1 -0
- package/dist/server/auth/verify.d.ts +48 -0
- package/dist/server/auth/verify.js +62 -0
- package/dist/server/auth/verify.js.map +1 -0
- package/dist/server/auth/verify.test.d.ts +1 -0
- package/dist/server/auth/verify.test.js +165 -0
- package/dist/server/auth/verify.test.js.map +1 -0
- package/dist/server/auth-extra.test-d.js +130 -0
- package/dist/server/auth-extra.test-d.js.map +1 -0
- package/dist/server/auth.d.ts +57 -0
- package/dist/server/auth.js +27 -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 +28 -0
- package/dist/server/build-manifest.test.js.map +1 -0
- package/dist/server/content-helpers.d.ts +41 -1
- package/dist/server/content-helpers.js +33 -0
- package/dist/server/content-helpers.js.map +1 -1
- package/dist/server/events.d.ts +113 -0
- package/dist/server/events.js +318 -0
- package/dist/server/events.js.map +1 -0
- package/dist/server/events.test.d.ts +1 -0
- package/dist/server/events.test.js +172 -0
- package/dist/server/events.test.js.map +1 -0
- package/dist/server/express.d.ts +24 -3
- package/dist/server/express.js +44 -32
- package/dist/server/express.js.map +1 -1
- package/dist/server/express.test.js +313 -90
- package/dist/server/express.test.js.map +1 -1
- 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/form-input.d.ts +120 -0
- package/dist/server/form-input.js +89 -0
- package/dist/server/form-input.js.map +1 -0
- package/dist/server/host.d.ts +2 -0
- package/dist/server/host.js +11 -0
- package/dist/server/host.js.map +1 -0
- package/dist/server/host.test.d.ts +1 -0
- package/dist/server/host.test.js +13 -0
- package/dist/server/host.test.js.map +1 -0
- package/dist/server/index.d.ts +20 -2
- package/dist/server/index.js +17 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/mcp-errors.test.d.ts +1 -0
- package/dist/server/mcp-errors.test.js +229 -0
- package/dist/server/mcp-errors.test.js.map +1 -0
- package/dist/server/metric.d.ts +5 -3
- package/dist/server/metric.js +5 -5
- package/dist/server/metric.js.map +1 -1
- package/dist/server/middleware.d.ts +51 -13
- package/dist/server/middleware.js +33 -0
- package/dist/server/middleware.js.map +1 -1
- package/dist/server/middleware.test-d.js +1 -1
- package/dist/server/middleware.test-d.js.map +1 -1
- package/dist/server/middleware.test.js +242 -134
- package/dist/server/middleware.test.js.map +1 -1
- package/dist/server/register-tool.test.d.ts +1 -0
- package/dist/server/register-tool.test.js +230 -0
- package/dist/server/register-tool.test.js.map +1 -0
- package/dist/server/requestOrigin.d.ts +7 -0
- package/dist/server/requestOrigin.js +25 -0
- package/dist/server/requestOrigin.js.map +1 -0
- package/dist/server/server.d.ts +535 -67
- package/dist/server/server.js +646 -315
- package/dist/server/server.js.map +1 -1
- package/dist/server/skills-integration.test.d.ts +1 -0
- package/dist/server/skills-integration.test.js +86 -0
- package/dist/server/skills-integration.test.js.map +1 -0
- package/dist/server/skills.d.ts +27 -0
- package/dist/server/skills.js +188 -0
- package/dist/server/skills.js.map +1 -0
- package/dist/server/skills.test.d.ts +1 -0
- package/dist/server/skills.test.js +243 -0
- package/dist/server/skills.test.js.map +1 -0
- package/dist/server/templateHelper.d.ts +0 -3
- package/dist/server/templateHelper.js.map +1 -1
- package/dist/server/templates.generated.js +4 -8
- package/dist/server/templates.generated.js.map +1 -1
- package/dist/server/tool-extra.test.d.ts +1 -0
- package/dist/server/tool-extra.test.js +167 -0
- package/dist/server/tool-extra.test.js.map +1 -0
- package/dist/server/view-name.test-d.d.ts +1 -0
- package/dist/server/view-name.test-d.js +8 -0
- package/dist/server/view-name.test-d.js.map +1 -0
- package/dist/server/view-resource-resolution.test.d.ts +6 -0
- package/dist/server/view-resource-resolution.test.js +176 -0
- package/dist/server/view-resource-resolution.test.js.map +1 -0
- package/dist/server/viewsDevServer.js +4 -1
- package/dist/server/viewsDevServer.js.map +1 -1
- package/dist/test/utils.d.ts +9 -11
- package/dist/test/utils.js +220 -201
- package/dist/test/utils.js.map +1 -1
- package/dist/test/view.test.js +123 -106
- package/dist/test/view.test.js.map +1 -1
- package/dist/views/index.d.ts +10 -0
- package/dist/views/index.js +3 -0
- package/dist/views/index.js.map +1 -0
- package/dist/{web/plugin → views}/scan-views.js +1 -1
- package/dist/views/scan-views.js.map +1 -0
- package/dist/views/scan-views.test.d.ts +1 -0
- package/dist/views/scan-views.test.js.map +1 -0
- package/dist/views/validate-view.d.ts +1 -0
- package/dist/{web/plugin → views}/validate-view.js +2 -2
- package/dist/views/validate-view.js.map +1 -0
- package/dist/views/validate-view.test.d.ts +1 -0
- package/dist/views/validate-view.test.js.map +1 -0
- package/dist/web/bridges/adaptor.d.ts +62 -0
- package/dist/web/bridges/adaptor.js +477 -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 +281 -0
- package/dist/web/bridges/adaptor.test.js.map +1 -0
- package/dist/web/bridges/apps-sdk/bridge.d.ts +6 -1
- package/dist/web/bridges/apps-sdk/bridge.js +15 -3
- package/dist/web/bridges/apps-sdk/bridge.js.map +1 -1
- package/dist/web/bridges/apps-sdk/index.d.ts +0 -1
- package/dist/web/bridges/apps-sdk/index.js +0 -1
- package/dist/web/bridges/apps-sdk/index.js.map +1 -1
- package/dist/web/bridges/apps-sdk/types.d.ts +4 -3
- 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/mcp-app/bridge.d.ts +15 -2
- package/dist/web/bridges/mcp-app/bridge.js +80 -7
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.test.d.ts +1 -0
- package/dist/web/bridges/mcp-app/bridge.test.js +17 -0
- package/dist/web/bridges/mcp-app/bridge.test.js.map +1 -0
- package/dist/web/bridges/mcp-app/index.d.ts +0 -1
- package/dist/web/bridges/mcp-app/index.js +0 -1
- package/dist/web/bridges/mcp-app/index.js.map +1 -1
- package/dist/web/bridges/mcp-app/types.d.ts +19 -2
- package/dist/web/bridges/mcp-app/types.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +13 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +12 -0
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
- package/dist/web/bridges/mcp-app/view-tools.test.d.ts +1 -0
- package/dist/web/bridges/mcp-app/view-tools.test.js +143 -0
- package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -0
- package/dist/web/bridges/types.d.ts +166 -5
- package/dist/web/bridges/types.js +14 -1
- package/dist/web/bridges/types.js.map +1 -1
- package/dist/web/bridges/types.test.d.ts +1 -0
- package/dist/web/bridges/types.test.js +19 -0
- package/dist/web/bridges/types.test.js.map +1 -0
- package/dist/web/bridges/use-host-context.d.ts +5 -0
- package/dist/web/bridges/use-host-context.js +5 -0
- package/dist/web/bridges/use-host-context.js.map +1 -1
- package/dist/web/components/modal-provider.d.ts +1 -1
- package/dist/web/components/modal-provider.js +4 -3
- package/dist/web/components/modal-provider.js.map +1 -1
- package/dist/web/create-store.d.ts +26 -0
- package/dist/web/create-store.js +26 -0
- package/dist/web/create-store.js.map +1 -1
- package/dist/web/create-store.test.js +10 -7
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.d.ts +34 -1
- package/dist/web/data-llm.js +31 -2
- package/dist/web/data-llm.js.map +1 -1
- package/dist/web/data-llm.test.js +26 -7
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +25 -19
- package/dist/web/generate-helpers.js +23 -17
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/generate-helpers.test-d.js +7 -5
- package/dist/web/generate-helpers.test-d.js.map +1 -1
- package/dist/web/generate-helpers.test.js +2 -2
- package/dist/web/generate-helpers.test.js.map +1 -1
- package/dist/web/hooks/index.d.ts +10 -1
- package/dist/web/hooks/index.js +10 -1
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/openai-extensions.test.d.ts +1 -0
- package/dist/web/hooks/openai-extensions.test.js +107 -0
- package/dist/web/hooks/openai-extensions.test.js.map +1 -0
- package/dist/web/hooks/test/utils.d.ts +7 -2
- package/dist/web/hooks/test/utils.js +14 -3
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-call-tool.d.ts +47 -2
- package/dist/web/hooks/use-call-tool.js +43 -10
- package/dist/web/hooks/use-call-tool.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test.js +75 -25
- package/dist/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/web/hooks/use-deep-link.d.ts +22 -0
- package/dist/web/hooks/use-deep-link.js +34 -0
- package/dist/web/hooks/use-deep-link.js.map +1 -0
- package/dist/web/hooks/use-display-mode.d.ts +20 -0
- package/dist/web/hooks/use-display-mode.js +20 -0
- package/dist/web/hooks/use-display-mode.js.map +1 -1
- package/dist/web/hooks/use-display-mode.test.js +57 -21
- package/dist/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/web/hooks/use-download.d.ts +3 -0
- package/dist/web/hooks/use-download.js +7 -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-file-resource.d.ts +37 -0
- package/dist/web/hooks/use-file-resource.js +98 -0
- package/dist/web/hooks/use-file-resource.js.map +1 -0
- package/dist/web/hooks/use-file-resource.test.d.ts +1 -0
- package/dist/web/hooks/use-file-resource.test.js +65 -0
- package/dist/web/hooks/use-file-resource.test.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +32 -0
- package/dist/web/hooks/use-files.js +32 -0
- package/dist/web/hooks/use-files.js.map +1 -1
- package/dist/web/hooks/use-files.test.js +11 -3
- package/dist/web/hooks/use-files.test.js.map +1 -1
- package/dist/web/hooks/use-host.d.ts +44 -0
- package/dist/web/hooks/use-host.js +45 -0
- package/dist/web/hooks/use-host.js.map +1 -0
- package/dist/web/hooks/use-host.test.d.ts +1 -0
- package/dist/web/hooks/use-host.test.js +59 -0
- package/dist/web/hooks/use-host.test.js.map +1 -0
- package/dist/web/hooks/use-model-context.d.ts +44 -0
- package/dist/web/hooks/use-model-context.js +63 -0
- package/dist/web/hooks/use-model-context.js.map +1 -0
- package/dist/web/hooks/use-open-external.d.ts +17 -0
- package/dist/web/hooks/use-open-external.js +16 -0
- package/dist/web/hooks/use-open-external.js.map +1 -1
- package/dist/web/hooks/use-open-external.test.js +15 -5
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-open-file.d.ts +20 -0
- package/dist/web/hooks/use-open-file.js +25 -0
- package/dist/web/hooks/use-open-file.js.map +1 -0
- package/dist/web/hooks/use-register-view-tool.d.ts +37 -0
- package/dist/web/hooks/use-register-view-tool.js +50 -0
- package/dist/web/hooks/use-register-view-tool.js.map +1 -0
- package/dist/web/hooks/use-request-close.d.ts +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 +16 -1
- package/dist/web/hooks/use-request-modal.js +16 -1
- package/dist/web/hooks/use-request-modal.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js +11 -1
- package/dist/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/web/hooks/use-request-size.d.ts +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 +25 -2
- package/dist/web/hooks/use-send-follow-up-message.js +23 -0
- package/dist/web/hooks/use-send-follow-up-message.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.d.ts +17 -0
- package/dist/web/hooks/use-set-open-in-app-url.js +17 -0
- package/dist/web/hooks/use-set-open-in-app-url.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.test.js +26 -12
- package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
- package/dist/web/hooks/use-tool-info.d.ts +46 -14
- package/dist/web/hooks/use-tool-info.js +29 -7
- package/dist/web/hooks/use-tool-info.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test-d.js +11 -34
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +42 -37
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.d.ts +5 -2
- package/dist/web/hooks/use-user.js +6 -3
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +85 -37
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/dist/web/hooks/use-view-state.d.ts +21 -0
- package/dist/web/hooks/use-view-state.js +19 -9
- package/dist/web/hooks/use-view-state.js.map +1 -1
- package/dist/web/hooks/use-view-state.test.js +39 -4
- package/dist/web/hooks/use-view-state.test.js.map +1 -1
- package/dist/web/hooks/use-viewport.d.ts +20 -0
- package/dist/web/hooks/use-viewport.js +21 -0
- package/dist/web/hooks/use-viewport.js.map +1 -0
- package/dist/web/hooks/use-viewport.test.d.ts +1 -0
- package/dist/web/hooks/use-viewport.test.js +109 -0
- package/dist/web/hooks/use-viewport.test.js.map +1 -0
- package/dist/web/mount-view.d.ts +20 -0
- package/dist/web/mount-view.js +22 -6
- package/dist/web/mount-view.js.map +1 -1
- package/dist/web/types.d.ts +4 -0
- package/dist/web/types.js.map +1 -1
- package/package.json +39 -27
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +0 -24
- package/dist/web/bridges/apps-sdk/adaptor.js +0 -96
- package/dist/web/bridges/apps-sdk/adaptor.js.map +0 -1
- package/dist/web/bridges/mcp-app/adaptor.d.ts +0 -48
- package/dist/web/bridges/mcp-app/adaptor.js +0 -263
- package/dist/web/bridges/mcp-app/adaptor.js.map +0 -1
- package/dist/web/hooks/use-layout.d.ts +0 -22
- package/dist/web/hooks/use-layout.js +0 -23
- package/dist/web/hooks/use-layout.js.map +0 -1
- package/dist/web/hooks/use-layout.test.js +0 -96
- package/dist/web/hooks/use-layout.test.js.map +0 -1
- package/dist/web/plugin/data-llm.test.js +0 -81
- package/dist/web/plugin/data-llm.test.js.map +0 -1
- package/dist/web/plugin/plugin.d.ts +0 -5
- package/dist/web/plugin/plugin.js +0 -156
- package/dist/web/plugin/plugin.js.map +0 -1
- package/dist/web/plugin/scan-views.js.map +0 -1
- package/dist/web/plugin/scan-views.test.js.map +0 -1
- package/dist/web/plugin/transform-data-llm.d.ts +0 -12
- package/dist/web/plugin/transform-data-llm.js +0 -96
- package/dist/web/plugin/transform-data-llm.js.map +0 -1
- package/dist/web/plugin/transform-data-llm.test.js +0 -81
- package/dist/web/plugin/transform-data-llm.test.js.map +0 -1
- package/dist/web/plugin/validate-view.d.ts +0 -1
- package/dist/web/plugin/validate-view.js.map +0 -1
- package/dist/web/plugin/validate-view.test.js.map +0 -1
- /package/dist/{web/hooks/use-layout.test.d.ts → cli/build-helpers.test.d.ts} +0 -0
- /package/dist/{web/plugin/data-llm.test.d.ts → cli/build-steps.test.d.ts} +0 -0
- /package/dist/{web/plugin/scan-views.test.d.ts → context-warnings.test.d.ts} +0 -0
- /package/dist/{web/plugin/transform-data-llm.test.d.ts → server/app.test.d.ts} +0 -0
- /package/dist/{web/plugin/validate-view.test.d.ts → server/auth-extra.test-d.d.ts} +0 -0
- /package/dist/{web/plugin → views}/scan-views.d.ts +0 -0
- /package/dist/{web/plugin → views}/scan-views.test.js +0 -0
- /package/dist/{web/plugin → views}/validate-view.test.js +0 -0
package/README.md
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
|
-
# Skybridge
|
|
1
|
+
# Skybridge - the MCP Apps framework
|
|
2
2
|
|
|
3
3
|
<p align="center">
|
|
4
4
|
<a href="https://docs.skybridge.tech">
|
|
5
|
-
<
|
|
5
|
+
<picture>
|
|
6
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/alpic-ai/skybridge/main/docs/images/skybridge-readme-banner-dark.png" />
|
|
7
|
+
<img alt="Skybridge, the full-stack React framework for MCP Apps and MCP servers" src="https://raw.githubusercontent.com/alpic-ai/skybridge/main/docs/images/skybridge-readme-banner-light.png" width="100%" />
|
|
8
|
+
</picture>
|
|
6
9
|
</a>
|
|
7
10
|
</p>
|
|
8
11
|
|
|
@@ -12,7 +15,7 @@
|
|
|
12
15
|
|
|
13
16
|
<p align="center">
|
|
14
17
|
<a href="https://docs.skybridge.tech">Documentation</a> ·
|
|
15
|
-
<a href="https://docs.skybridge.tech/quickstart
|
|
18
|
+
<a href="https://docs.skybridge.tech/get-started/quickstart">Quickstart</a> ·
|
|
16
19
|
<a href="https://github.com/alpic-ai/skybridge/tree/main/examples">Examples</a>
|
|
17
20
|
</p>
|
|
18
21
|
|
|
@@ -25,85 +28,86 @@
|
|
|
25
28
|
|
|
26
29
|
## About Skybridge
|
|
27
30
|
|
|
28
|
-
Skybridge helps developers build type-safe MCP Apps for Claude, ChatGPT
|
|
31
|
+
Skybridge helps developers build type-safe MCP Apps for Claude, ChatGPT and other UI-enabled MCP clients, with a complete set of tooling designed for both humans and agents.
|
|
29
32
|
|
|
30
|
-
MCP Apps extend the [Model Context Protocol](https://modelcontextprotocol.io/docs/getting-started/intro) with **rich, interactive UI views** rendered from MCP servers. Conversational apps need seamless interaction between the user, the UI, and the model. This means new UX patterns, developer tooling, and abstractions.
|
|
33
|
+
Why? MCP Apps extend the [Model Context Protocol](https://modelcontextprotocol.io/docs/getting-started/intro) with **rich, interactive UI views** rendered from MCP servers. Conversational apps need seamless interaction between the user, the UI, and the model. This means new UX patterns, developer tooling, and abstractions.
|
|
34
|
+
Plus, the raw SDKs are low-level: no hooks, type safety, HMR, etc.
|
|
35
|
+
|
|
36
|
+
That's why we built *Skybridge*.
|
|
31
37
|
|
|
32
38
|
Features include:
|
|
33
39
|
|
|
34
|
-
- **Delightful dev environment**:
|
|
35
|
-
- **Write once, run everywhere**:
|
|
36
|
-
- **Agent-ready**:
|
|
37
|
-
- **Type-safe end-to-end**: tRPC-style inference from MCP server tool definition to React view for type
|
|
40
|
+
- **Delightful dev environment**: Skybridge provides a dev server with a local emulator, hot module reload, and a permanent tunnel to connect your local app to Claude and ChatGPT.
|
|
41
|
+
- **Write once, run everywhere**: the framework abstracts implementation differences between MCP clients, so your app runs seamlessly in Claude, ChatGPT, VSCode, and any other MCP Apps compatible client.
|
|
42
|
+
- **Agent-ready**: powerful skills, CLI, and programmatic dev tool APIs, everything your coding agent needs to build MCP Apps end-to-end.
|
|
43
|
+
- **Type-safe end-to-end**: tRPC-style inference from MCP server tool definition to React view for type safety from server to frontend.
|
|
38
44
|
- **React-first**: Intuitive React Query-style hooks, with advanced state management.
|
|
39
|
-
- **
|
|
45
|
+
- **Example library**: get started quickly with ChatGPT- and Claude-ready app examples for ecommerce, travel, SaaS, and more.
|
|
40
46
|
|
|
41
|
-
|
|
47
|
+
They chose to build their MCP Apps with Skybridge:
|
|
42
48
|
|
|
43
49
|
<p align="center">
|
|
44
|
-
<a href="https://www.datadoghq.com"><picture><source media="(prefers-color-scheme: dark)" srcset="docs/images/user-logos/datadog-dark.svg"><img src="docs/images/user-logos/datadog-light.svg" alt="Datadog" height="24"></picture></a>
|
|
50
|
+
<a href="https://www.datadoghq.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/alpic-ai/skybridge/main/docs/images/user-logos/datadog-dark.svg"><img src="https://raw.githubusercontent.com/alpic-ai/skybridge/main/docs/images/user-logos/datadog-light.svg" alt="Datadog" height="24"></picture></a>
|
|
45
51
|
|
|
46
|
-
<a href="https://bitmovin.com"><picture><source media="(prefers-color-scheme: dark)" srcset="docs/images/user-logos/bitmovin-dark.svg"><img src="docs/images/user-logos/bitmovin-light.svg" alt="Bitmovin" height="22"></picture></a>
|
|
52
|
+
<a href="https://bitmovin.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/alpic-ai/skybridge/main/docs/images/user-logos/bitmovin-dark.svg"><img src="https://raw.githubusercontent.com/alpic-ai/skybridge/main/docs/images/user-logos/bitmovin-light.svg" alt="Bitmovin" height="22"></picture></a>
|
|
47
53
|
|
|
48
|
-
<a href="https://www.evaneos.com"><picture><source media="(prefers-color-scheme: dark)" srcset="docs/images/user-logos/evaneos-dark.svg"><img src="docs/images/user-logos/evaneos-light.svg" alt="Evaneos" height="18"></picture></a>
|
|
54
|
+
<a href="https://www.evaneos.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/alpic-ai/skybridge/main/docs/images/user-logos/evaneos-dark.svg"><img src="https://raw.githubusercontent.com/alpic-ai/skybridge/main/docs/images/user-logos/evaneos-light.svg" alt="Evaneos" height="18"></picture></a>
|
|
49
55
|
|
|
50
|
-
<a href="https://www.touchstream.media"><picture><source media="(prefers-color-scheme: dark)" srcset="docs/images/user-logos/touchstream-dark.svg"><img src="docs/images/user-logos/touchstream-light.svg" alt="Touchstream" height="24"></picture></a>
|
|
56
|
+
<a href="https://www.touchstream.media"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/alpic-ai/skybridge/main/docs/images/user-logos/touchstream-dark.svg"><img src="https://raw.githubusercontent.com/alpic-ai/skybridge/main/docs/images/user-logos/touchstream-light.svg" alt="Touchstream" height="24"></picture></a>
|
|
51
57
|
|
|
52
|
-
<a href="https://www.cottages.com"><picture><source media="(prefers-color-scheme: dark)" srcset="docs/images/user-logos/cottages-dark.svg"><img src="docs/images/user-logos/cottages-light.svg" alt="Cottages.com" height="24"></picture></a>
|
|
58
|
+
<a href="https://www.cottages.com"><picture><source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/alpic-ai/skybridge/main/docs/images/user-logos/cottages-dark.svg"><img src="https://raw.githubusercontent.com/alpic-ai/skybridge/main/docs/images/user-logos/cottages-light.svg" alt="Cottages.com" height="24"></picture></a>
|
|
53
59
|
</p>
|
|
54
60
|
|
|
55
61
|
## Get started
|
|
56
62
|
|
|
57
63
|
**For agents**
|
|
58
64
|
|
|
59
|
-
Install our [
|
|
65
|
+
Install our [skill](https://docs.skybridge.tech/guides/migrate) for building MCP Apps and ChatGPT plugins:
|
|
60
66
|
```bash
|
|
61
67
|
npx skills add alpic-ai/skybridge -s skybridge
|
|
62
68
|
```
|
|
63
|
-
Once installed,
|
|
69
|
+
Once installed, ask your agent "What skills do you have?" to confirm, then try:
|
|
64
70
|
|
|
65
|
-
- _Create a new MCP
|
|
66
|
-
- _Migrate my MCP
|
|
67
|
-
- _Add a new view to my MCP
|
|
71
|
+
- _Create a new MCP app_
|
|
72
|
+
- _Migrate my MCP server to the Skybridge framework_
|
|
73
|
+
- _Add a new view to my MCP app_
|
|
68
74
|
|
|
69
75
|
**For humans**
|
|
70
76
|
|
|
71
77
|
Bootstrap a new project with:
|
|
72
78
|
```bash
|
|
73
|
-
npm create skybridge my-app
|
|
79
|
+
npm create skybridge@latest my-app
|
|
74
80
|
```
|
|
75
|
-
For full install instructions, read
|
|
81
|
+
For full install instructions, read our [**Quickstart guide**](https://docs.skybridge.tech/get-started/quickstart).
|
|
76
82
|
|
|
77
83
|
## Documentation
|
|
78
84
|
|
|
79
85
|
The [Skybridge documentation](https://docs.skybridge.tech) covers the full lifecycle of building MCP Apps:
|
|
80
86
|
|
|
81
|
-
- [Fundamentals](https://docs.skybridge.tech/
|
|
82
|
-
- [Core concepts](https://docs.skybridge.tech/
|
|
83
|
-
- [Guides](https://docs.skybridge.tech/
|
|
87
|
+
- [Fundamentals](https://docs.skybridge.tech/get-started/architecture): understand MCP Apps, ChatGPT plugins, and how Skybridge bridges both runtimes.
|
|
88
|
+
- [Core concepts](https://docs.skybridge.tech/get-started/architecture): learn about server <> model <> UI data flows, LLM context sync, type safety, and instant local iteration with our devtools.
|
|
89
|
+
- [Guides](https://docs.skybridge.tech/build/tools): build real app behavior with tools, views, state, and model communication.
|
|
84
90
|
- [API Reference](https://docs.skybridge.tech/api-reference): browse our MCP server APIs, React hooks, CLI commands, and runtime compatibility.
|
|
85
91
|
|
|
86
92
|
## Deploy
|
|
87
93
|
|
|
88
|
-
Deploy Skybridge apps instantly on [Alpic](https://alpic.ai)
|
|
94
|
+
Deploy Skybridge apps instantly on [Alpic](https://alpic.ai) for scalable hosting, MCP-specific analytics, permanent tunneling, plugin directory compliance auditing and submission help. You can also self-host on any Node.js-compatible platform.
|
|
89
95
|
|
|
90
|
-
|
|
96
|
+
See our [deployment guide](https://docs.skybridge.tech/ship/deploy) for the full production path.
|
|
91
97
|
|
|
92
98
|
## Community & Contributing
|
|
93
99
|
|
|
94
|
-
We
|
|
95
|
-
|
|
96
|
-
Here are a few ways you can get involved:
|
|
100
|
+
We'd love your help improving Skybridge. Here are a few ways to get involved:
|
|
97
101
|
|
|
98
|
-
- **
|
|
99
|
-
- **Questions and
|
|
100
|
-
- **Pull requests**: For code or documentation changes,
|
|
102
|
+
- **Bugs**: If you run into a bug or unexpected behavior, open a [GitHub Issue](https://github.com/alpic-ai/skybridge/issues) with a clear reproduction.
|
|
103
|
+
- **Questions and ideas**: Need help building with Skybridge or have ideas to improve the framework, docs, examples, or developer experience? [Open an issue](https://github.com/alpic-ai/skybridge/issues) or share them on our [Discord](https://discord.com/invite/gNAazGueab).
|
|
104
|
+
- **Pull requests**: For code or documentation changes, read the [Contributing Guide](https://github.com/alpic-ai/skybridge/blob/main/CONTRIBUTING.md) before opening a PR.
|
|
101
105
|
|
|
102
106
|
Skybridge is released under the [MIT License](https://github.com/alpic-ai/skybridge/blob/main/LICENSE).
|
|
103
107
|
|
|
104
108
|
### Contributors
|
|
105
109
|
|
|
106
|
-
Built and maintained by [Harijoe](https://github.com/harijoe), [Fred Barthelet](https://github.com/fredericbarthelet), and the [Alpic](https://alpic.ai) team.
|
|
110
|
+
Built and maintained with ❤️ by [Harijoe](https://github.com/harijoe), [Fred Barthelet](https://github.com/fredericbarthelet), and the [Alpic](https://alpic.ai) team.
|
|
107
111
|
|
|
108
112
|
<a href="https://github.com/alpic-ai/skybridge/graphs/contributors">
|
|
109
113
|
<img src="https://contrib.rocks/image?repo=alpic-ai/skybridge" alt="Skybridge contributors">
|
|
@@ -113,24 +117,39 @@ Built and maintained by [Harijoe](https://github.com/harijoe), [Fred Barthelet](
|
|
|
113
117
|
|
|
114
118
|
Explore all our example templates in the [Examples](https://docs.skybridge.tech/examples) section of the documentation.
|
|
115
119
|
|
|
120
|
+
### Basic
|
|
121
|
+
|
|
122
|
+
| Preview | App | Description | Demo | Code |
|
|
123
|
+
| --- | --- | --- | --- | --- |
|
|
124
|
+
| <img src="docs/images/showcase-example.png" alt="Everything" width="160" /> | Everything | Comprehensive playground app showcasing all Skybridge hooks and features. | [Try Demo](https://everything.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/everything) |
|
|
125
|
+
|
|
126
|
+
### Use cases
|
|
127
|
+
|
|
116
128
|
| Preview | App | Description | Demo | Code |
|
|
117
129
|
| --- | --- | --- | --- | --- |
|
|
118
130
|
| <img src="docs/images/showcase-capitals.png" alt="Capitals Explorer" width="160" /> | Capitals Explorer | Interactive world map with geolocation, country information, and dynamic capital exploration. | [Try Demo](https://capitals.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/capitals) |
|
|
119
131
|
| <img src="docs/images/showcase-flight-booking.png" alt="Flight Booking" width="160" /> | Flight Booking | Flight search carousel with route details, pricing comparison, and external booking. | [Try Demo](https://flight-booking.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/flight-booking) |
|
|
120
132
|
| <img src="docs/images/showcase-ecommerce.png" alt="Ecommerce Carousel" width="160" /> | Ecommerce Carousel | Product carousel with persistent cart, localization, theme switching, and modal dialogs. | [Try Demo](https://ecommerce.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/ecom-carousel) |
|
|
121
|
-
| <img src="docs/images/showcase-
|
|
122
|
-
| <img src="docs/images/showcase-
|
|
123
|
-
| <img src="docs/images/showcase-productivity.png" alt="Productivity" width="160" /> | Productivity | Data visualization dashboard demonstrating Skybridge capabilities for MCP Apps. | [Try Demo](https://productivity.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/productivity) |
|
|
133
|
+
| <img src="docs/images/showcase-investigation-game.png" alt="Investigation Game" width="160" /> | Investigation Game | Multi-screen mystery game with fullscreen mode, dynamic story progression and context asynchronicity demonstration | [Try Demo](https://investigation-game.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/investigation-game) |
|
|
134
|
+
| <img src="docs/images/showcase-productivity.png" alt="Productivity" width="160" /> | Productivity | Interactive analytics dashboard with charts, theme adaptation, localization, fullscreen mode, and bidirectional tool calls. | [Try Demo](https://productivity.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/productivity) |
|
|
124
135
|
| <img src="docs/images/showcase-times-up.png" alt="Time's Up" width="160" /> | Time's Up | Word-guessing party game where the user gives hints and the AI tries to guess. | [Try Demo](https://times-up.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/times-up) |
|
|
125
|
-
| <img src="docs/images/showcase-manifest-ui.png" alt="Manifest UI" width="160" /> | Manifest UI | Agentic component library example for rich AI-powered experiences. | [Try Demo](https://manifest-ui.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/manifest-ui) |
|
|
126
|
-
| <img src="docs/images/showcase-generative-ui.png" alt="Generative UI" width="160" /> | Generative UI | LLM-generated dynamic UIs with json-render and 36 pre-built shadcn/ui components. | [Try Demo](https://generative-ui.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/generative-ui) |
|
|
127
136
|
| <img src="docs/images/showcase-lumo.png" alt="Lumo Interactive AI Tutor" width="160" /> | Lumo — Interactive AI Tutor | Adaptive tutor with Mermaid diagrams, mind maps, quizzes, and fill-in-the-blank exercises. | [Try Demo](https://lumo-mcp-app-39519fdd.alpic.live/try) | [View code](https://github.com/connorads/lumo-mcp-app) |
|
|
128
137
|
|
|
129
|
-
###
|
|
138
|
+
### Auth
|
|
130
139
|
|
|
131
140
|
| Preview | Provider | Description | Code |
|
|
132
141
|
| --- | --- | --- | --- |
|
|
142
|
+
| <img src="docs/images/descope.webp" alt="Auth Descope" width="160" /> | Descope | Full OAuth authentication with Descope and personalized coffee shop search. | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-descope) |
|
|
133
143
|
| <img src="docs/images/showcase-clerk.png" alt="Auth Clerk" width="160" /> | Clerk | Full OAuth authentication with Clerk and personalized coffee shop search. | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-clerk) |
|
|
134
144
|
| <img src="docs/images/showcase-workos.png" alt="Auth WorkOS AuthKit" width="160" /> | WorkOS AuthKit | Full OAuth authentication with WorkOS AuthKit and personalized coffee shop search. | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-workos) |
|
|
135
145
|
| <img src="docs/images/showcase-stytch.png" alt="Auth Stytch" width="160" /> | Stytch | Full OAuth authentication with Stytch and personalized coffee shop search. | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-stytch) |
|
|
136
146
|
| <img src="docs/images/showcase-auth0.png" alt="Auth Auth0" width="160" /> | Auth0 | Full OAuth authentication with Auth0 and personalized coffee shop search. | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-auth0) |
|
|
147
|
+
| <img src="docs/images/showcase-authplane.png" alt="Auth Authplane" width="160" /> | Authplane | Full OAuth authentication with Authplane and personalized coffee shop search. | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-authplane) |
|
|
148
|
+
|
|
149
|
+
### UI and component libraries
|
|
150
|
+
|
|
151
|
+
| Preview | App | Description | Demo | Code |
|
|
152
|
+
| --- | --- | --- | --- | --- |
|
|
153
|
+
| <img src="docs/images/showcase-manifest-ui.png" alt="Manifest UI" width="160" /> | Manifest UI | Agentic component library example for rich AI-powered experiences. | [Try Demo](https://manifest-ui.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/manifest-ui) |
|
|
154
|
+
| <img src="docs/images/showcase-generative-ui.png" alt="Generative UI" width="160" /> | Generative UI | LLM-generated dynamic UIs with json-render and 36 pre-built shadcn/ui components. | [Try Demo](https://generative-ui.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/generative-ui) |
|
|
155
|
+
| <img src="docs/images/showcase-mcpcn.png" alt="mcpcn" width="160" /> | mcpcn | Agentic component library starter with pre-built mcpcn components and generative UI via json-render. | [Try Demo](https://mcpcn.skybridge.tech/try) | [View code](https://github.com/alpic-ai/skybridge/tree/main/examples/mcpcn) |
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const ENTRY_WRAPPER_CONTENT = "import { __setBuildManifest, __setSkillsManifest } from \"skybridge/server\";\nimport manifest from \"./vite-manifest.js\";\nimport skills from \"./skills.js\";\n\n__setBuildManifest(manifest);\n__setSkillsManifest(skills);\n\nconst userMod = await import(\"./index.js\");\nexport default userMod.default;\n";
|
|
2
|
+
export declare function emitEntryWrapper(distDir: string): void;
|
|
3
|
+
export declare function emitSkillsModule(skillsDir: string, outPath: string): void;
|
|
4
|
+
export declare function emitManifestModule(manifestPath: string, outPath: string): void;
|
|
5
|
+
/** Emit an empty Vite manifest for view-less (headless) servers. */
|
|
6
|
+
export declare function emitEmptyManifestModule(outPath: string): void;
|
|
7
|
+
export declare function ensureAssetsDir(assetsDir: string): void;
|
|
8
|
+
export declare const VERCEL_FUNCTION_NAME = "mcp";
|
|
9
|
+
export declare const IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
10
|
+
export declare function readHashedAssetPaths(root: string): string[];
|
|
11
|
+
export declare function buildCloudflareHeaders(hashedAssetPaths: string[]): string;
|
|
12
|
+
export declare function buildVercelConfig(hashedAssetPaths?: string[]): unknown;
|
|
13
|
+
export declare const VERCEL_VC_CONFIG: unknown;
|
|
14
|
+
export declare function emitVercelBuildOutput(root: string, serverExternal?: string[], publicDir?: string | null): Promise<void>;
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import { cpSync, existsSync, mkdirSync, readFileSync, rmSync, writeFileSync, } from "node:fs";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
import { discoverSkills } from "../server/skills.js";
|
|
4
|
+
// Primes the manifest and skills snapshot in skybridge's module scope, then
|
|
5
|
+
// dynamically imports `./index.js` so user code runs *after* the side channels
|
|
6
|
+
// are set. The dynamic import is load-bearing: a static
|
|
7
|
+
// `export { default } from ...` is hoisted with the rest of the static graph
|
|
8
|
+
// and would evaluate `index.js` before the primers run. Both `skills.js` and
|
|
9
|
+
// the manifest are imported (not read from disk) so they ride the bundle on
|
|
10
|
+
// filesystem-less targets like Cloudflare Workers.
|
|
11
|
+
export const ENTRY_WRAPPER_CONTENT = `import { __setBuildManifest, __setSkillsManifest } from "skybridge/server";
|
|
12
|
+
import manifest from "./vite-manifest.js";
|
|
13
|
+
import skills from "./skills.js";
|
|
14
|
+
|
|
15
|
+
__setBuildManifest(manifest);
|
|
16
|
+
__setSkillsManifest(skills);
|
|
17
|
+
|
|
18
|
+
const userMod = await import("./index.js");
|
|
19
|
+
export default userMod.default;
|
|
20
|
+
`;
|
|
21
|
+
export function emitEntryWrapper(distDir) {
|
|
22
|
+
writeFileSync(path.join(distDir, "__entry.js"), ENTRY_WRAPPER_CONTENT);
|
|
23
|
+
}
|
|
24
|
+
export function emitSkillsModule(skillsDir, outPath) {
|
|
25
|
+
const skills = discoverSkills(skillsDir);
|
|
26
|
+
writeFileSync(outPath, `export default ${JSON.stringify(skills)};\n`);
|
|
27
|
+
}
|
|
28
|
+
export function emitManifestModule(manifestPath, outPath) {
|
|
29
|
+
const manifest = readFileSync(manifestPath, "utf-8");
|
|
30
|
+
writeFileSync(outPath, `export default ${manifest};\n`);
|
|
31
|
+
}
|
|
32
|
+
/** Emit an empty Vite manifest for view-less (headless) servers. */
|
|
33
|
+
export function emitEmptyManifestModule(outPath) {
|
|
34
|
+
writeFileSync(outPath, "export default {};\n");
|
|
35
|
+
}
|
|
36
|
+
export function ensureAssetsDir(assetsDir) {
|
|
37
|
+
mkdirSync(assetsDir, { recursive: true });
|
|
38
|
+
}
|
|
39
|
+
export const VERCEL_FUNCTION_NAME = "mcp";
|
|
40
|
+
export const IMMUTABLE_CACHE_CONTROL = "public, max-age=31536000, immutable";
|
|
41
|
+
// Only files listed in the Vite manifest are content-hashed: `public/` is copied
|
|
42
|
+
// into the same folder with stable names, so a folder-wide rule would freeze them.
|
|
43
|
+
export function readHashedAssetPaths(root) {
|
|
44
|
+
const manifestPath = path.join(root, "dist", "assets", ".vite", "manifest.json");
|
|
45
|
+
if (!existsSync(manifestPath)) {
|
|
46
|
+
return [];
|
|
47
|
+
}
|
|
48
|
+
const manifest = JSON.parse(readFileSync(manifestPath, "utf-8"));
|
|
49
|
+
const files = Object.values(manifest).flatMap((chunk) => [
|
|
50
|
+
chunk.file,
|
|
51
|
+
...(chunk.css ?? []),
|
|
52
|
+
...(chunk.assets ?? []),
|
|
53
|
+
]);
|
|
54
|
+
return [...new Set(files)].sort().map((file) => `/assets/${file}`);
|
|
55
|
+
}
|
|
56
|
+
// ponytail: one rule per hashed file; Cloudflare caps `_headers` at 100 rules, switch to a dedicated hashed folder if apps outgrow it.
|
|
57
|
+
export function buildCloudflareHeaders(hashedAssetPaths) {
|
|
58
|
+
const immutableRules = hashedAssetPaths.map((assetPath) => `\n${assetPath}\n Cache-Control: ${IMMUTABLE_CACHE_CONTROL}\n`);
|
|
59
|
+
return `/assets/*\n Access-Control-Allow-Origin: *\n${immutableRules.join("")}`;
|
|
60
|
+
}
|
|
61
|
+
const escapeRegExp = (value) => value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
62
|
+
export function buildVercelConfig(hashedAssetPaths = []) {
|
|
63
|
+
return {
|
|
64
|
+
version: 3,
|
|
65
|
+
routes: [
|
|
66
|
+
{
|
|
67
|
+
src: "/assets/(.*)",
|
|
68
|
+
headers: { "Access-Control-Allow-Origin": "*" },
|
|
69
|
+
continue: true,
|
|
70
|
+
},
|
|
71
|
+
...hashedAssetPaths.map((assetPath) => ({
|
|
72
|
+
src: escapeRegExp(assetPath),
|
|
73
|
+
headers: { "Cache-Control": IMMUTABLE_CACHE_CONTROL },
|
|
74
|
+
continue: true,
|
|
75
|
+
})),
|
|
76
|
+
{ handle: "filesystem" },
|
|
77
|
+
{ src: "/(.*)", dest: `/${VERCEL_FUNCTION_NAME}` },
|
|
78
|
+
],
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
export const VERCEL_VC_CONFIG = {
|
|
82
|
+
runtime: "nodejs22.x",
|
|
83
|
+
handler: "index.js",
|
|
84
|
+
launcherType: "Nodejs",
|
|
85
|
+
shouldAddHelpers: true,
|
|
86
|
+
};
|
|
87
|
+
// Emit a Build Output API tree under `.vercel/output/`. Bundling the server
|
|
88
|
+
// with esbuild produces a self-contained function bundle, so we don't ship
|
|
89
|
+
// `node_modules` and don't touch tracked paths like `api/` or `public/`.
|
|
90
|
+
//
|
|
91
|
+
// Entry is `dist/__entry.js` — the wrapper that primes the Vite manifest via
|
|
92
|
+
// `__setBuildManifest` before importing user code. Bundling `dist/index.js`
|
|
93
|
+
// directly would skip that priming and 500 on view resource reads when the
|
|
94
|
+
// function falls back to `readFileSync('dist/assets/.vite/manifest.json')`
|
|
95
|
+
// (Vercel functions don't ship `dist/`).
|
|
96
|
+
export async function emitVercelBuildOutput(root, serverExternal = [], publicDir) {
|
|
97
|
+
const outputDir = path.join(root, ".vercel", "output");
|
|
98
|
+
const funcDir = path.join(outputDir, "functions", `${VERCEL_FUNCTION_NAME}.func`);
|
|
99
|
+
const staticAssetsDir = path.join(outputDir, "static", "assets");
|
|
100
|
+
rmSync(outputDir, { recursive: true, force: true });
|
|
101
|
+
mkdirSync(funcDir, { recursive: true });
|
|
102
|
+
const { build } = await import("esbuild");
|
|
103
|
+
await build({
|
|
104
|
+
entryPoints: [path.join(root, "dist", "__entry.js")],
|
|
105
|
+
bundle: true,
|
|
106
|
+
platform: "node",
|
|
107
|
+
target: "node22",
|
|
108
|
+
format: "esm",
|
|
109
|
+
outfile: path.join(funcDir, "index.js"),
|
|
110
|
+
// Lets esbuild DCE dev-only branches that pull in vite/devtools.
|
|
111
|
+
define: { "process.env.NODE_ENV": '"production"' },
|
|
112
|
+
// Dev-only deps reachable from re-exports; safe to leave unresolved since
|
|
113
|
+
// the code paths that touch them are eliminated by the NODE_ENV define.
|
|
114
|
+
// `serverExternal` comes from the vite plugin, for deps esbuild can't
|
|
115
|
+
// resolve or load (e.g. optional native modules pulled in transitively).
|
|
116
|
+
external: ["vite", "@skybridge/devtools", ...serverExternal],
|
|
117
|
+
// Native addons can't be inlined into the bundle; copy them next to the
|
|
118
|
+
// function and rewrite the require path to point at the copy.
|
|
119
|
+
loader: { ".node": "file" },
|
|
120
|
+
banner: {
|
|
121
|
+
// ESM bundles miss CJS interop globals that some deps reach for.
|
|
122
|
+
js: "import{createRequire}from'node:module';const require=createRequire(import.meta.url);",
|
|
123
|
+
},
|
|
124
|
+
});
|
|
125
|
+
writeFileSync(path.join(funcDir, ".vc-config.json"), `${JSON.stringify(VERCEL_VC_CONFIG, null, 2)}\n`);
|
|
126
|
+
writeFileSync(path.join(funcDir, "package.json"), `${JSON.stringify({ type: "module" }, null, 2)}\n`);
|
|
127
|
+
const assetsSrc = path.join(root, "dist", "assets");
|
|
128
|
+
if (existsSync(assetsSrc)) {
|
|
129
|
+
cpSync(assetsSrc, staticAssetsDir, { recursive: true });
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
mkdirSync(staticAssetsDir, { recursive: true });
|
|
133
|
+
}
|
|
134
|
+
if (publicDir !== null) {
|
|
135
|
+
const resolvedPublicDir = publicDir ?? path.join(root, "public");
|
|
136
|
+
if (existsSync(resolvedPublicDir)) {
|
|
137
|
+
cpSync(resolvedPublicDir, path.join(outputDir, "static"), {
|
|
138
|
+
recursive: true,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
writeFileSync(path.join(outputDir, "config.json"), `${JSON.stringify(buildVercelConfig(readHashedAssetPaths(root)), null, 2)}\n`);
|
|
143
|
+
}
|
|
144
|
+
//# sourceMappingURL=build-helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-helpers.js","sourceRoot":"","sources":["../../src/cli/build-helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,MAAM,EACN,UAAU,EACV,SAAS,EACT,YAAY,EACZ,MAAM,EACN,aAAa,GACd,MAAM,SAAS,CAAC;AACjB,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAErD,4EAA4E;AAC5E,+EAA+E;AAC/E,wDAAwD;AACxD,6EAA6E;AAC7E,6EAA6E;AAC7E,4EAA4E;AAC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AAE,CAAC;QACvB,MAAM,iBAAiB,GAAG,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;QACjE,IAAI,UAAU,CAAC,iBAAiB,CAAC,EAAE,CAAC;YAClC,MAAM,CAAC,iBAAiB,EAAE,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,EAAE;gBACxD,SAAS,EAAE,IAAI;aAChB,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED,aAAa,CACX,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,aAAa,CAAC,EACnC,GAAG,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,oBAAoB,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,IAAI,CAC9E,CAAC;AACJ,CAAC","sourcesContent":["import {\n cpSync,\n existsSync,\n mkdirSync,\n readFileSync,\n rmSync,\n writeFileSync,\n} from \"node:fs\";\nimport path from \"node:path\";\nimport { discoverSkills } from \"../server/skills.js\";\n\n// Primes the manifest and skills snapshot in skybridge's module scope, then\n// dynamically imports `./index.js` so user code runs *after* the side channels\n// are set. The dynamic import is load-bearing: a static\n// `export { default } from ...` is hoisted with the rest of the static graph\n// and would evaluate `index.js` before the primers run. Both `skills.js` and\n// the manifest are imported (not read from disk) so they ride the bundle on\n// filesystem-less targets like Cloudflare Workers.\nexport const ENTRY_WRAPPER_CONTENT = `import { __setBuildManifest, __setSkillsManifest } from \"skybridge/server\";\nimport manifest from \"./vite-manifest.js\";\nimport skills from \"./skills.js\";\n\n__setBuildManifest(manifest);\n__setSkillsManifest(skills);\n\nconst userMod = await import(\"./index.js\");\nexport default userMod.default;\n`;\n\nexport function emitEntryWrapper(distDir: string): void {\n writeFileSync(path.join(distDir, \"__entry.js\"), ENTRY_WRAPPER_CONTENT);\n}\n\nexport function emitSkillsModule(skillsDir: string, outPath: string): void {\n const skills = discoverSkills(skillsDir);\n writeFileSync(outPath, `export default ${JSON.stringify(skills)};\\n`);\n}\n\nexport function emitManifestModule(\n manifestPath: string,\n outPath: string,\n): void {\n const manifest = readFileSync(manifestPath, \"utf-8\");\n writeFileSync(outPath, `export default ${manifest};\\n`);\n}\n\n/** Emit an empty Vite manifest for view-less (headless) servers. */\nexport function emitEmptyManifestModule(outPath: string): void {\n writeFileSync(outPath, \"export default {};\\n\");\n}\n\nexport function ensureAssetsDir(assetsDir: string): void {\n mkdirSync(assetsDir, { recursive: true });\n}\n\nexport const VERCEL_FUNCTION_NAME = \"mcp\";\n\nexport const IMMUTABLE_CACHE_CONTROL = \"public, max-age=31536000, immutable\";\n\n// Only files listed in the Vite manifest are content-hashed: `public/` is copied\n// into the same folder with stable names, so a folder-wide rule would freeze them.\nexport function readHashedAssetPaths(root: string): string[] {\n const manifestPath = path.join(\n root,\n \"dist\",\n \"assets\",\n \".vite\",\n \"manifest.json\",\n );\n if (!existsSync(manifestPath)) {\n return [];\n }\n const manifest: Record<\n string,\n { file: string; css?: string[]; assets?: string[] }\n > = JSON.parse(readFileSync(manifestPath, \"utf-8\"));\n const files = Object.values(manifest).flatMap((chunk) => [\n chunk.file,\n ...(chunk.css ?? []),\n ...(chunk.assets ?? []),\n ]);\n return [...new Set(files)].sort().map((file) => `/assets/${file}`);\n}\n\n// ponytail: one rule per hashed file; Cloudflare caps `_headers` at 100 rules, switch to a dedicated hashed folder if apps outgrow it.\nexport function buildCloudflareHeaders(hashedAssetPaths: string[]): string {\n const immutableRules = hashedAssetPaths.map(\n (assetPath) =>\n `\\n${assetPath}\\n Cache-Control: ${IMMUTABLE_CACHE_CONTROL}\\n`,\n );\n return `/assets/*\\n Access-Control-Allow-Origin: *\\n${immutableRules.join(\"\")}`;\n}\n\nconst escapeRegExp = (value: string) =>\n value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n\nexport function buildVercelConfig(hashedAssetPaths: string[] = []): unknown {\n return {\n version: 3,\n routes: [\n {\n src: \"/assets/(.*)\",\n headers: { \"Access-Control-Allow-Origin\": \"*\" },\n continue: true,\n },\n ...hashedAssetPaths.map((assetPath) => ({\n src: escapeRegExp(assetPath),\n headers: { \"Cache-Control\": IMMUTABLE_CACHE_CONTROL },\n continue: true,\n })),\n { handle: \"filesystem\" },\n { src: \"/(.*)\", dest: `/${VERCEL_FUNCTION_NAME}` },\n ],\n };\n}\n\nexport const VERCEL_VC_CONFIG: unknown = {\n runtime: \"nodejs22.x\",\n handler: \"index.js\",\n launcherType: \"Nodejs\",\n shouldAddHelpers: true,\n};\n\n// Emit a Build Output API tree under `.vercel/output/`. Bundling the server\n// with esbuild produces a self-contained function bundle, so we don't ship\n// `node_modules` and don't touch tracked paths like `api/` or `public/`.\n//\n// Entry is `dist/__entry.js` — the wrapper that primes the Vite manifest via\n// `__setBuildManifest` before importing user code. Bundling `dist/index.js`\n// directly would skip that priming and 500 on view resource reads when the\n// function falls back to `readFileSync('dist/assets/.vite/manifest.json')`\n// (Vercel functions don't ship `dist/`).\nexport async function emitVercelBuildOutput(\n root: string,\n serverExternal: string[] = [],\n publicDir?: string | null,\n): Promise<void> {\n const outputDir = path.join(root, \".vercel\", \"output\");\n const funcDir = path.join(\n outputDir,\n \"functions\",\n `${VERCEL_FUNCTION_NAME}.func`,\n );\n const staticAssetsDir = path.join(outputDir, \"static\", \"assets\");\n\n rmSync(outputDir, { recursive: true, force: true });\n mkdirSync(funcDir, { recursive: true });\n\n const { build } = await import(\"esbuild\");\n await build({\n entryPoints: [path.join(root, \"dist\", \"__entry.js\")],\n bundle: true,\n platform: \"node\",\n target: \"node22\",\n format: \"esm\",\n outfile: path.join(funcDir, \"index.js\"),\n // Lets esbuild DCE dev-only branches that pull in vite/devtools.\n define: { \"process.env.NODE_ENV\": '\"production\"' },\n // Dev-only deps reachable from re-exports; safe to leave unresolved since\n // the code paths that touch them are eliminated by the NODE_ENV define.\n // `serverExternal` comes from the vite plugin, for deps esbuild can't\n // resolve or load (e.g. optional native modules pulled in transitively).\n external: [\"vite\", \"@skybridge/devtools\", ...serverExternal],\n // Native addons can't be inlined into the bundle; copy them next to the\n // function and rewrite the require path to point at the copy.\n loader: { \".node\": \"file\" },\n banner: {\n // ESM bundles miss CJS interop globals that some deps reach for.\n js: \"import{createRequire}from'node:module';const require=createRequire(import.meta.url);\",\n },\n });\n\n writeFileSync(\n path.join(funcDir, \".vc-config.json\"),\n `${JSON.stringify(VERCEL_VC_CONFIG, null, 2)}\\n`,\n );\n writeFileSync(\n path.join(funcDir, \"package.json\"),\n `${JSON.stringify({ type: \"module\" }, null, 2)}\\n`,\n );\n\n const assetsSrc = path.join(root, \"dist\", \"assets\");\n if (existsSync(assetsSrc)) {\n cpSync(assetsSrc, staticAssetsDir, { recursive: true });\n } else {\n mkdirSync(staticAssetsDir, { recursive: true });\n }\n\n if (publicDir !== null) {\n const resolvedPublicDir = publicDir ?? path.join(root, \"public\");\n if (existsSync(resolvedPublicDir)) {\n cpSync(resolvedPublicDir, path.join(outputDir, \"static\"), {\n recursive: true,\n });\n }\n }\n\n writeFileSync(\n path.join(outputDir, \"config.json\"),\n `${JSON.stringify(buildVercelConfig(readHashedAssetPaths(root)), null, 2)}\\n`,\n );\n}\n"]}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// @vitest-environment node
|
|
2
|
+
// esbuild's invariant check on TextEncoder/Uint8Array trips jsdom's polyfill.
|
|
3
|
+
import { existsSync, mkdirSync, mkdtempSync, readFileSync, writeFileSync, } from "node:fs";
|
|
4
|
+
import { tmpdir } from "node:os";
|
|
5
|
+
import path from "node:path";
|
|
6
|
+
import { describe, expect, it } from "vitest";
|
|
7
|
+
import { buildCloudflareHeaders, buildVercelConfig, ENTRY_WRAPPER_CONTENT, emitEmptyManifestModule, emitEntryWrapper, emitManifestModule, emitSkillsModule, emitVercelBuildOutput, ensureAssetsDir, IMMUTABLE_CACHE_CONTROL, readHashedAssetPaths, VERCEL_VC_CONFIG, } from "./build-helpers.js";
|
|
8
|
+
function mkTmp(prefix = "skybridge-build-helpers-") {
|
|
9
|
+
return mkdtempSync(path.join(tmpdir(), prefix));
|
|
10
|
+
}
|
|
11
|
+
describe("emitEntryWrapper", () => {
|
|
12
|
+
it("writes dist/__entry.js that primes the manifest before importing user code", () => {
|
|
13
|
+
const dir = mkTmp();
|
|
14
|
+
emitEntryWrapper(dir);
|
|
15
|
+
const out = readFileSync(path.join(dir, "__entry.js"), "utf-8");
|
|
16
|
+
expect(out).toBe(ENTRY_WRAPPER_CONTENT);
|
|
17
|
+
expect(out).toContain('import { __setBuildManifest, __setSkillsManifest } from "skybridge/server"');
|
|
18
|
+
expect(out).toContain('import manifest from "./vite-manifest.js"');
|
|
19
|
+
expect(out).toContain('import skills from "./skills.js"');
|
|
20
|
+
expect(out).toContain("__setBuildManifest(manifest)");
|
|
21
|
+
expect(out).toContain("__setSkillsManifest(skills)");
|
|
22
|
+
// Dynamic import is load-bearing: `index.js` must evaluate after the
|
|
23
|
+
// setters run, so a static re-export wouldn't work.
|
|
24
|
+
expect(out).toContain('await import("./index.js")');
|
|
25
|
+
expect(out).toContain("export default userMod.default");
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
describe("emitSkillsModule", () => {
|
|
29
|
+
it("inlines discovered skills as an ESM default export", () => {
|
|
30
|
+
const dir = mkTmp();
|
|
31
|
+
const skillsDir = path.join(dir, "src", "skills");
|
|
32
|
+
mkdirSync(path.join(skillsDir, "refunds"), { recursive: true });
|
|
33
|
+
writeFileSync(path.join(skillsDir, "refunds", "SKILL.md"), "---\nname: refunds\ndescription: Process refunds\n---\nBody");
|
|
34
|
+
const outPath = path.join(dir, "skills.js");
|
|
35
|
+
emitSkillsModule(skillsDir, outPath);
|
|
36
|
+
const out = readFileSync(outPath, "utf-8");
|
|
37
|
+
const literal = out
|
|
38
|
+
.slice("export default ".length)
|
|
39
|
+
.trim()
|
|
40
|
+
.replace(/;$/, "");
|
|
41
|
+
const skills = JSON.parse(literal);
|
|
42
|
+
expect(skills).toHaveLength(1);
|
|
43
|
+
expect(skills[0]).toMatchObject({
|
|
44
|
+
uri: "skill://refunds/SKILL.md",
|
|
45
|
+
frontmatter: { name: "refunds", description: "Process refunds" },
|
|
46
|
+
});
|
|
47
|
+
expect(skills[0].resources).toHaveLength(1);
|
|
48
|
+
expect(skills[0].resources[0].uri).toBe("skill://refunds/SKILL.md");
|
|
49
|
+
expect(skills[0].resources[0].digest).toMatch(/^sha256:[a-f0-9]{64}$/);
|
|
50
|
+
});
|
|
51
|
+
it("emits an empty array when the skills directory is absent", () => {
|
|
52
|
+
const dir = mkTmp();
|
|
53
|
+
const outPath = path.join(dir, "skills.js");
|
|
54
|
+
emitSkillsModule(path.join(dir, "nope"), outPath);
|
|
55
|
+
expect(readFileSync(outPath, "utf-8")).toBe("export default [];\n");
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
describe("emitManifestModule", () => {
|
|
59
|
+
it("inlines the JSON manifest as an ESM default export", () => {
|
|
60
|
+
const dir = mkTmp();
|
|
61
|
+
const inPath = path.join(dir, "manifest.json");
|
|
62
|
+
const outPath = path.join(dir, "vite-manifest.js");
|
|
63
|
+
const manifest = { "src/views/foo.tsx": { file: "assets/foo-abc.js" } };
|
|
64
|
+
writeFileSync(inPath, JSON.stringify(manifest));
|
|
65
|
+
emitManifestModule(inPath, outPath);
|
|
66
|
+
const out = readFileSync(outPath, "utf-8");
|
|
67
|
+
expect(out.startsWith("export default ")).toBe(true);
|
|
68
|
+
const literal = out
|
|
69
|
+
.slice("export default ".length)
|
|
70
|
+
.trim()
|
|
71
|
+
.replace(/;$/, "");
|
|
72
|
+
expect(JSON.parse(literal)).toEqual(manifest);
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
describe("emitEmptyManifestModule", () => {
|
|
76
|
+
it("writes an empty object default export", () => {
|
|
77
|
+
const dir = mkTmp();
|
|
78
|
+
const outPath = path.join(dir, "vite-manifest.js");
|
|
79
|
+
emitEmptyManifestModule(outPath);
|
|
80
|
+
expect(readFileSync(outPath, "utf-8")).toBe("export default {};\n");
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
describe("ensureAssetsDir", () => {
|
|
84
|
+
it("creates the assets directory when missing", () => {
|
|
85
|
+
const dir = mkTmp();
|
|
86
|
+
const assetsDir = path.join(dir, "dist", "assets");
|
|
87
|
+
ensureAssetsDir(assetsDir);
|
|
88
|
+
expect(existsSync(assetsDir)).toBe(true);
|
|
89
|
+
});
|
|
90
|
+
});
|
|
91
|
+
describe("emitVercelBuildOutput", () => {
|
|
92
|
+
it("emits a Build Output API tree with bundled function and static assets", async () => {
|
|
93
|
+
const root = mkTmp();
|
|
94
|
+
mkdirSync(path.join(root, "dist", "assets"), { recursive: true });
|
|
95
|
+
writeFileSync(path.join(root, "dist", "server.js"), "export default function handler(_req, res) { res.end('ok'); }\n");
|
|
96
|
+
// Minimal `dist/__entry.js` (the real wrapper imports `skybridge/server`,
|
|
97
|
+
// which isn't resolvable in this test's tmp dir — the function-bundling
|
|
98
|
+
// contract we care about here is just "bundle whatever `__entry.js`
|
|
99
|
+
// imports into a single function file").
|
|
100
|
+
writeFileSync(path.join(root, "dist", "__entry.js"), "const userMod = await import('./server.js');\nexport default userMod.default;\n");
|
|
101
|
+
writeFileSync(path.join(root, "dist", "assets", "view-abc.js"), "/* bundled view */\n");
|
|
102
|
+
await emitVercelBuildOutput(root);
|
|
103
|
+
const outputDir = path.join(root, ".vercel", "output");
|
|
104
|
+
const funcDir = path.join(outputDir, "functions", "mcp.func");
|
|
105
|
+
expect(existsSync(path.join(funcDir, "index.js"))).toBe(true);
|
|
106
|
+
expect(JSON.parse(readFileSync(path.join(funcDir, ".vc-config.json"), "utf-8"))).toEqual(VERCEL_VC_CONFIG);
|
|
107
|
+
expect(JSON.parse(readFileSync(path.join(funcDir, "package.json"), "utf-8"))).toEqual({ type: "module" });
|
|
108
|
+
expect(JSON.parse(readFileSync(path.join(outputDir, "config.json"), "utf-8"))).toEqual(buildVercelConfig());
|
|
109
|
+
expect(readFileSync(path.join(outputDir, "static", "assets", "view-abc.js"), "utf-8")).toContain("bundled view");
|
|
110
|
+
});
|
|
111
|
+
it("copies public/ to Vercel static root for root-level serving", async () => {
|
|
112
|
+
const root = mkTmp();
|
|
113
|
+
mkdirSync(path.join(root, "dist", "assets"), { recursive: true });
|
|
114
|
+
mkdirSync(path.join(root, "public", ".well-known"), { recursive: true });
|
|
115
|
+
writeFileSync(path.join(root, "dist", "__entry.js"), "const userMod = await import('./server.js');\nexport default userMod.default;\n");
|
|
116
|
+
writeFileSync(path.join(root, "dist", "server.js"), "export default function handler(_req, res) { res.end('ok'); }\n");
|
|
117
|
+
writeFileSync(path.join(root, "public", ".well-known", "openai-apps-challenge"), "challenge-token");
|
|
118
|
+
await emitVercelBuildOutput(root);
|
|
119
|
+
const outputDir = path.join(root, ".vercel", "output");
|
|
120
|
+
expect(readFileSync(path.join(outputDir, "static", ".well-known", "openai-apps-challenge"), "utf-8")).toBe("challenge-token");
|
|
121
|
+
});
|
|
122
|
+
it("skips public copy when publicDir is null (disabled)", async () => {
|
|
123
|
+
const root = mkTmp();
|
|
124
|
+
mkdirSync(path.join(root, "dist", "assets"), { recursive: true });
|
|
125
|
+
mkdirSync(path.join(root, "public"), { recursive: true });
|
|
126
|
+
writeFileSync(path.join(root, "dist", "__entry.js"), "const userMod = await import('./server.js');\nexport default userMod.default;\n");
|
|
127
|
+
writeFileSync(path.join(root, "dist", "server.js"), "export default function handler(_req, res) { res.end('ok'); }\n");
|
|
128
|
+
writeFileSync(path.join(root, "public", "secret.txt"), "should-not-copy");
|
|
129
|
+
writeFileSync(path.join(root, "dist", "assets", "view.js"), "/* view */");
|
|
130
|
+
await emitVercelBuildOutput(root, [], null);
|
|
131
|
+
const outputDir = path.join(root, ".vercel", "output");
|
|
132
|
+
expect(existsSync(path.join(outputDir, "static", "secret.txt"))).toBe(false);
|
|
133
|
+
expect(readFileSync(path.join(outputDir, "static", "assets", "view.js"), "utf-8")).toContain("view");
|
|
134
|
+
});
|
|
135
|
+
it("leaves serverExternal packages unbundled", async () => {
|
|
136
|
+
const root = mkTmp();
|
|
137
|
+
mkdirSync(path.join(root, "dist"), { recursive: true });
|
|
138
|
+
// Unresolvable from the tmp root, so esbuild fails the build unless the
|
|
139
|
+
// package is marked external (bunyan → optional `dtrace-provider`).
|
|
140
|
+
writeFileSync(path.join(root, "dist", "__entry.js"), 'import "dtrace-provider";\nexport default null;\n');
|
|
141
|
+
await expect(emitVercelBuildOutput(root)).rejects.toThrow(/Could not resolve "dtrace-provider"/);
|
|
142
|
+
await emitVercelBuildOutput(root, ["dtrace-provider"]);
|
|
143
|
+
const bundle = readFileSync(path.join(root, ".vercel", "output", "functions", "mcp.func", "index.js"), "utf-8");
|
|
144
|
+
expect(bundle).toContain('import "dtrace-provider"');
|
|
145
|
+
});
|
|
146
|
+
it("emits static assets directory when dist/assets is missing", async () => {
|
|
147
|
+
const root = mkTmp();
|
|
148
|
+
mkdirSync(path.join(root, "dist"), { recursive: true });
|
|
149
|
+
writeFileSync(path.join(root, "dist", "__entry.js"), "const userMod = await import('./server.js');\nexport default userMod.default;\n");
|
|
150
|
+
writeFileSync(path.join(root, "dist", "server.js"), "export default function handler(_req, res) { res.end('ok'); }\n");
|
|
151
|
+
await emitVercelBuildOutput(root);
|
|
152
|
+
expect(existsSync(path.join(root, ".vercel", "output", "static", "assets"))).toBe(true);
|
|
153
|
+
expect(existsSync(path.join(root, ".vercel", "output", "functions", "mcp.func", "index.js"))).toBe(true);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
describe("asset cache headers", () => {
|
|
157
|
+
function rootWithManifestAndNestedPublicAsset() {
|
|
158
|
+
const root = mkTmp();
|
|
159
|
+
const assetsDir = path.join(root, "dist", "assets");
|
|
160
|
+
mkdirSync(path.join(assetsDir, ".vite"), { recursive: true });
|
|
161
|
+
mkdirSync(path.join(assetsDir, "assets"), { recursive: true });
|
|
162
|
+
writeFileSync(path.join(assetsDir, ".vite", "manifest.json"), JSON.stringify({
|
|
163
|
+
"src/views/a.tsx": {
|
|
164
|
+
file: "assets/a-Ab12Cd34.js",
|
|
165
|
+
css: ["assets/style-Ef56Gh78.css"],
|
|
166
|
+
assets: ["assets/icons-Ij90Kl12.svg"],
|
|
167
|
+
},
|
|
168
|
+
_shared: { file: "assets/a-Ab12Cd34.js" },
|
|
169
|
+
}));
|
|
170
|
+
// Copied from `public/assets/logo.svg`: same folder, stable name.
|
|
171
|
+
writeFileSync(path.join(assetsDir, "assets", "logo.svg"), "<svg/>");
|
|
172
|
+
return root;
|
|
173
|
+
}
|
|
174
|
+
it("lists only manifest files as hashed assets", () => {
|
|
175
|
+
expect(readHashedAssetPaths(rootWithManifestAndNestedPublicAsset())).toEqual([
|
|
176
|
+
"/assets/assets/a-Ab12Cd34.js",
|
|
177
|
+
"/assets/assets/icons-Ij90Kl12.svg",
|
|
178
|
+
"/assets/assets/style-Ef56Gh78.css",
|
|
179
|
+
]);
|
|
180
|
+
expect(readHashedAssetPaths(mkTmp())).toEqual([]);
|
|
181
|
+
});
|
|
182
|
+
it("marks hashed files immutable and leaves public files alone", () => {
|
|
183
|
+
const hashed = readHashedAssetPaths(rootWithManifestAndNestedPublicAsset());
|
|
184
|
+
const headers = buildCloudflareHeaders(hashed);
|
|
185
|
+
expect(headers).toContain("/assets/*\n Access-Control-Allow-Origin: *\n");
|
|
186
|
+
expect(headers).toContain(`/assets/assets/a-Ab12Cd34.js\n Cache-Control: ${IMMUTABLE_CACHE_CONTROL}\n`);
|
|
187
|
+
expect(headers).not.toContain("logo.svg");
|
|
188
|
+
expect(headers).not.toContain("/assets/assets/*");
|
|
189
|
+
const routes = buildVercelConfig(hashed)
|
|
190
|
+
.routes;
|
|
191
|
+
expect(routes).toContainEqual({
|
|
192
|
+
src: "/assets/assets/a-Ab12Cd34\\.js",
|
|
193
|
+
headers: { "Cache-Control": IMMUTABLE_CACHE_CONTROL },
|
|
194
|
+
continue: true,
|
|
195
|
+
});
|
|
196
|
+
expect(routes.map((route) => route.src).join()).not.toContain("logo");
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
//# sourceMappingURL=build-helpers.test.js.map
|