skybridge 0.0.0-dev.ecfdeac → 0.0.0-dev.ed005a8
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 +10 -16
- package/dist/cli/build-helpers.d.ts +6 -2
- package/dist/cli/build-helpers.js +39 -14
- package/dist/cli/build-helpers.js.map +1 -1
- package/dist/cli/build-helpers.test.js +73 -5
- package/dist/cli/build-helpers.test.js.map +1 -1
- 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.js +0 -1
- 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 +5 -0
- package/dist/cli/{resolve-views-dir.js → resolve-skybridge-config.js} +4 -3
- 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 +89 -0
- package/dist/cli/run-plain.js.map +1 -0
- package/dist/cli/use-execute-steps.d.ts +1 -1
- package/dist/cli/use-nodemon.d.ts +14 -0
- package/dist/cli/use-nodemon.js +81 -62
- 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 +70 -67
- package/dist/cli/use-typescript-check.js.map +1 -1
- package/dist/commands/build.d.ts +0 -2
- package/dist/commands/build.js +2 -61
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/dev.d.ts +1 -0
- package/dist/commands/dev.js +35 -3
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.js +2 -2
- 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 +194 -0
- package/dist/server/app.js +266 -0
- package/dist/server/app.js.map +1 -0
- package/dist/server/app.test.js +97 -0
- package/dist/server/app.test.js.map +1 -0
- package/dist/server/auth/discovery.d.ts +2 -1
- package/dist/server/auth/discovery.js +2 -2
- package/dist/server/auth/discovery.js.map +1 -1
- package/dist/server/auth/index.d.ts +35 -5
- package/dist/server/auth/index.js.map +1 -1
- package/dist/server/auth/providers/auth0.d.ts +25 -3
- package/dist/server/auth/providers/auth0.js +13 -8
- package/dist/server/auth/providers/auth0.js.map +1 -1
- package/dist/server/auth/providers/auth0.test.js +5 -3
- package/dist/server/auth/providers/auth0.test.js.map +1 -1
- 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.js +143 -0
- package/dist/server/auth/providers/authplane.test.js.map +1 -0
- package/dist/server/auth/providers/clerk.d.ts +40 -3
- package/dist/server/auth/providers/clerk.js +4 -1
- package/dist/server/auth/providers/clerk.js.map +1 -1
- package/dist/server/auth/providers/clerk.test.js +5 -3
- package/dist/server/auth/providers/clerk.test.js.map +1 -1
- package/dist/server/auth/providers/custom.d.ts +20 -4
- package/dist/server/auth/providers/custom.js +33 -11
- package/dist/server/auth/providers/custom.js.map +1 -1
- package/dist/server/auth/providers/custom.test.js +71 -17
- package/dist/server/auth/providers/custom.test.js.map +1 -1
- package/dist/server/auth/providers/descope.d.ts +37 -6
- package/dist/server/auth/providers/descope.js +18 -5
- package/dist/server/auth/providers/descope.js.map +1 -1
- package/dist/server/auth/providers/descope.test.js +42 -17
- package/dist/server/auth/providers/descope.test.js.map +1 -1
- package/dist/server/auth/providers/stytch.d.ts +16 -3
- package/dist/server/auth/providers/stytch.js +4 -1
- package/dist/server/auth/providers/stytch.js.map +1 -1
- 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 +25 -3
- package/dist/server/auth/providers/workos.js +4 -1
- package/dist/server/auth/providers/workos.js.map +1 -1
- 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 +3 -1
- package/dist/server/auth/setup.js +66 -26
- package/dist/server/auth/setup.js.map +1 -1
- package/dist/server/auth/setup.test.js +349 -20
- package/dist/server/auth/setup.test.js.map +1 -1
- package/dist/server/auth/verify.d.ts +37 -3
- package/dist/server/auth/verify.js +27 -3
- package/dist/server/auth/verify.js.map +1 -1
- package/dist/server/auth/verify.test.js +49 -0
- package/dist/server/auth/verify.test.js.map +1 -1
- 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 +43 -6
- package/dist/server/auth.js +4 -5
- package/dist/server/auth.js.map +1 -1
- package/dist/server/build-manifest.test.js +7 -6
- package/dist/server/build-manifest.test.js.map +1 -1
- package/dist/server/content-helpers.d.ts +1 -1
- package/dist/server/content-helpers.js.map +1 -1
- package/dist/server/express.d.ts +23 -3
- package/dist/server/express.js +38 -32
- package/dist/server/express.js.map +1 -1
- package/dist/server/express.test.js +220 -103
- package/dist/server/express.test.js.map +1 -1
- package/dist/server/file-ref.d.ts +1 -1
- package/dist/server/file-ref.js +1 -1
- package/dist/server/file-ref.js.map +1 -1
- 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 +16 -9
- package/dist/server/index.js +9 -3
- 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 +41 -0
- package/dist/server/mcp-errors.test.js.map +1 -0
- package/dist/server/middleware.d.ts +35 -10
- 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 +27 -0
- package/dist/server/register-tool.test.js.map +1 -0
- package/dist/server/server.d.ts +133 -116
- package/dist/server/server.js +251 -346
- 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 +88 -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.js +105 -17
- package/dist/server/view-resource-resolution.test.js.map +1 -1
- 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 +105 -133
- 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 +51 -0
- package/dist/web/bridges/adaptor.js +327 -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 +225 -0
- package/dist/web/bridges/adaptor.test.js.map +1 -0
- package/dist/web/bridges/apps-sdk/bridge.d.ts +6 -2
- package/dist/web/bridges/apps-sdk/bridge.js +15 -4
- 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/use-apps-sdk-context.d.ts +1 -1
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js +1 -1
- package/dist/web/bridges/apps-sdk/use-apps-sdk-context.js.map +1 -1
- package/dist/web/bridges/get-adaptor.d.ts +4 -4
- package/dist/web/bridges/get-adaptor.js +6 -11
- 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 +13 -2
- package/dist/web/bridges/mcp-app/bridge.js +52 -8
- 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 +2 -0
- package/dist/web/bridges/mcp-app/types.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +1 -1
- 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.js +6 -7
- package/dist/web/bridges/mcp-app/view-tools.test.js.map +1 -1
- package/dist/web/bridges/types.d.ts +27 -12
- 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/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.test.js +10 -7
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.d.ts +1 -1
- package/dist/web/data-llm.test.js +20 -7
- 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 +19 -15
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/generate-helpers.test-d.js +3 -3
- 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 +2 -1
- package/dist/web/hooks/index.js +2 -1
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/test/utils.d.ts +2 -1
- package/dist/web/hooks/test/utils.js +1 -1
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-call-tool.test.js +39 -25
- package/dist/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/web/hooks/use-display-mode.d.ts +1 -1
- package/dist/web/hooks/use-display-mode.js +1 -1
- 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 +1 -3
- package/dist/web/hooks/use-download.js +1 -2
- package/dist/web/hooks/use-download.js.map +1 -1
- package/dist/web/hooks/use-download.test.js +18 -10
- package/dist/web/hooks/use-download.test.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 +22 -0
- package/dist/web/hooks/use-host.js +30 -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-open-external.test.js +15 -5
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-register-view-tool.d.ts +2 -3
- package/dist/web/hooks/use-register-view-tool.js.map +1 -1
- package/dist/web/hooks/use-request-close.test.js +35 -40
- package/dist/web/hooks/use-request-close.test.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 +1 -1
- package/dist/web/hooks/use-request-size.js +1 -1
- package/dist/web/hooks/use-request-size.js.map +1 -1
- package/dist/web/hooks/use-request-size.test.js +35 -53
- package/dist/web/hooks/use-request-size.test.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 +1 -20
- package/dist/web/hooks/use-tool-info.js +0 -1
- package/dist/web/hooks/use-tool-info.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test-d.js +0 -5
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +38 -33
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.d.ts +3 -2
- package/dist/web/hooks/use-user.js +4 -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.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 +3 -2
- package/dist/web/mount-view.js +5 -8
- package/dist/web/mount-view.js.map +1 -1
- package/package.json +31 -28
- package/dist/cli/resolve-views-dir.d.ts +0 -1
- package/dist/cli/resolve-views-dir.js.map +0 -1
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +0 -29
- package/dist/web/bridges/apps-sdk/adaptor.js +0 -117
- package/dist/web/bridges/apps-sdk/adaptor.js.map +0 -1
- package/dist/web/bridges/mcp-app/adaptor.d.ts +0 -53
- package/dist/web/bridges/mcp-app/adaptor.js +0 -283
- package/dist/web/bridges/mcp-app/adaptor.js.map +0 -1
- package/dist/web/hooks/use-layout.d.ts +0 -24
- package/dist/web/hooks/use-layout.js +0 -25
- 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 -33
- package/dist/web/plugin/plugin.js +0 -189
- 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-steps.test.d.ts} +0 -0
- /package/dist/{web/plugin/data-llm.test.d.ts → context-warnings.test.d.ts} +0 -0
- /package/dist/{web/plugin/scan-views.test.d.ts → server/app.test.d.ts} +0 -0
- /package/dist/{web/plugin/validate-view.test.d.ts → server/auth/providers/authplane.test.d.ts} +0 -0
- /package/dist/{web/plugin/transform-data-llm.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/dist/commands/build.js
CHANGED
|
@@ -1,74 +1,15 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { rmSync, writeFileSync } from "node:fs";
|
|
3
|
-
import path from "node:path";
|
|
4
2
|
import { Command } from "@oclif/core";
|
|
5
3
|
import { Box, render, Text } from "ink";
|
|
6
4
|
import { useEffect } from "react";
|
|
7
|
-
import {
|
|
5
|
+
import { getCommandSteps } from "../cli/build-steps.js";
|
|
8
6
|
import { Header } from "../cli/header.js";
|
|
9
|
-
import { resolveViewsDir } from "../cli/resolve-views-dir.js";
|
|
10
7
|
import { useExecuteSteps } from "../cli/use-execute-steps.js";
|
|
11
|
-
import { scanAndWriteViewsDts } from "../web/plugin/scan-views.js";
|
|
12
|
-
export const commandSteps = [
|
|
13
|
-
{
|
|
14
|
-
label: "Scanning views",
|
|
15
|
-
run: async () => {
|
|
16
|
-
const root = process.cwd();
|
|
17
|
-
const viewsDir = await resolveViewsDir(root);
|
|
18
|
-
scanAndWriteViewsDts(root, viewsDir);
|
|
19
|
-
},
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
label: "Compiling server",
|
|
23
|
-
run: () => rmSync("dist", { recursive: true, force: true }),
|
|
24
|
-
command: "tsc -b --force",
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
label: "Building views",
|
|
28
|
-
command: "vite build",
|
|
29
|
-
},
|
|
30
|
-
{
|
|
31
|
-
label: "Emitting manifest module",
|
|
32
|
-
// Inline the Vite manifest as a JS module so the wrapper can `import` it
|
|
33
|
-
// instead of `readFileSync(process.cwd() + ...)` at runtime — required for
|
|
34
|
-
// workerd, where neither cwd nor the assets directory is readable.
|
|
35
|
-
run: () => {
|
|
36
|
-
const root = process.cwd();
|
|
37
|
-
emitManifestModule(path.join(root, "dist", "assets", ".vite", "manifest.json"), path.join(root, "dist", "vite-manifest.js"));
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
{
|
|
41
|
-
label: "Emitting entry wrapper",
|
|
42
|
-
// dist/__entry.js primes the Vite manifest via __setBuildManifest, then
|
|
43
|
-
// dynamically imports user code. Deploy targets (Cloudflare, Vercel)
|
|
44
|
-
// bundle from here so the manifest is available at runtime.
|
|
45
|
-
run: () => {
|
|
46
|
-
emitEntryWrapper(path.join(process.cwd(), "dist"));
|
|
47
|
-
},
|
|
48
|
-
},
|
|
49
|
-
{
|
|
50
|
-
label: "Emitting Cloudflare redirects",
|
|
51
|
-
run: () => {
|
|
52
|
-
const root = process.cwd();
|
|
53
|
-
writeFileSync(path.join(root, "dist", "assets", "_redirects"), "/assets/assets/* /assets/:splat 200\n");
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
{
|
|
57
|
-
label: "Emitting Cloudflare headers",
|
|
58
|
-
run: () => {
|
|
59
|
-
const root = process.cwd();
|
|
60
|
-
writeFileSync(path.join(root, "dist", "assets", "_headers"), "/assets/*\n Access-Control-Allow-Origin: *\n");
|
|
61
|
-
},
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
label: "Emitting Vercel build output",
|
|
65
|
-
run: () => emitVercelBuildOutput(process.cwd()),
|
|
66
|
-
},
|
|
67
|
-
];
|
|
68
8
|
export default class Build extends Command {
|
|
69
9
|
static description = "Build the views and MCP server";
|
|
70
10
|
static examples = ["skybridge build"];
|
|
71
11
|
async run() {
|
|
12
|
+
const commandSteps = await getCommandSteps().catch((e) => this.error(e instanceof Error ? e.message : String(e)));
|
|
72
13
|
const App = () => {
|
|
73
14
|
const { currentStep, status, error, execute } = useExecuteSteps(commandSteps);
|
|
74
15
|
useEffect(() => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,eAAe,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AI,IAAC,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,aAC1D,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,EAAE,GAAG,EAC9D,IAAI,CAAC,KAAK,IACN,IAJC,IAAI,CAAC,KAAK,CAKd,CACP,CAAC;oBACJ,CAAC,CAAC,EAED,MAAM,KAAK,SAAS,IAAI,CACvB,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,YACf,KAAC,IAAI,IAAC,KAAK,EAAC,OAAO,EAAC,IAAI,2DAEjB,GACH,CACP,EAEA,MAAM,KAAK,OAAO,IAAI,KAAK,IAAI,CAC9B,MAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,aACvC,KAAC,IAAI,IAAC,KAAK,EAAC,KAAK,EAAC,IAAI,0CAEf,EACP,KAAC,GAAG,IAAC,SAAS,EAAE,CAAC,EAAE,aAAa,EAAC,QAAQ,YACtC,KAAK,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAC/B,KAAC,IAAI,IAAY,KAAK,EAAC,KAAK,YACzB,IAAI,IADI,IAAI,CAER,CACR,CAAC,GACE,IACF,CACP,IACG,CACP,CAAC;QACJ,CAAC,CAAC;QAEF,MAAM,CAAC,KAAC,GAAG,KAAG,EAAE;YACd,WAAW,EAAE,IAAI;YACjB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC","sourcesContent":["import { Command } from \"@oclif/core\";\nimport { Box, render, Text } from \"ink\";\nimport { useEffect } from \"react\";\nimport { getCommandSteps } from \"../cli/build-steps.js\";\nimport { Header } from \"../cli/header.js\";\nimport { useExecuteSteps } from \"../cli/use-execute-steps.js\";\n\nexport default class Build extends Command {\n static override description = \"Build the views and MCP server\";\n static override examples = [\"skybridge build\"];\n\n public async run(): Promise<void> {\n const commandSteps = await getCommandSteps().catch((e: unknown) =>\n this.error(e instanceof Error ? e.message : String(e)),\n );\n\n const App = () => {\n const { currentStep, status, error, execute } =\n useExecuteSteps(commandSteps);\n\n useEffect(() => {\n execute();\n }, [execute]);\n\n return (\n <Box flexDirection=\"column\" padding={1}>\n <Header version={this.config.version}>\n <Text color=\"green\"> → building for production…</Text>\n </Header>\n\n {commandSteps.map((step, index) => {\n const isCurrent = index === currentStep && status === \"running\";\n const isCompleted = index < currentStep || status === \"success\";\n const isError = status === \"error\" && index === currentStep;\n\n return (\n <Box key={step.label} marginBottom={0}>\n <Text color={isError ? \"red\" : isCompleted ? \"green\" : \"grey\"}>\n {isError ? \"✗\" : isCompleted ? \"✓\" : isCurrent ? \"⟳\" : \"○\"}{\" \"}\n {step.label}\n </Text>\n </Box>\n );\n })}\n\n {status === \"success\" && (\n <Box marginTop={1}>\n <Text color=\"green\" bold>\n ✓ Build completed successfully!\n </Text>\n </Box>\n )}\n\n {status === \"error\" && error && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"red\" bold>\n ✗ Build failed\n </Text>\n <Box marginTop={1} flexDirection=\"column\">\n {error.split(\"\\n\").map((line) => (\n <Text key={line} color=\"red\">\n {line}\n </Text>\n ))}\n </Box>\n </Box>\n )}\n </Box>\n );\n };\n\n render(<App />, {\n exitOnCtrlC: true,\n patchConsole: false,\n });\n }\n}\n"]}
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export default class Dev extends Command {
|
|
|
7
7
|
tunnel: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
8
|
open: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
9
9
|
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
|
+
plain: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
10
11
|
};
|
|
11
12
|
run(): Promise<void>;
|
|
12
13
|
}
|
package/dist/commands/dev.js
CHANGED
|
@@ -3,14 +3,15 @@ import { Command, Flags } from "@oclif/core";
|
|
|
3
3
|
import { Box, render, Text } from "ink";
|
|
4
4
|
import { resolvePort } from "../cli/detect-port.js";
|
|
5
5
|
import { Header } from "../cli/header.js";
|
|
6
|
-
import {
|
|
6
|
+
import { resolveSkybridgeConfig } from "../cli/resolve-skybridge-config.js";
|
|
7
|
+
import { runPlain } from "../cli/run-plain.js";
|
|
7
8
|
import { startTunnelControlServer } from "../cli/tunnel-control-server.js";
|
|
8
9
|
import { useMessages } from "../cli/use-messages.js";
|
|
9
10
|
import { useNodemon } from "../cli/use-nodemon.js";
|
|
10
11
|
import { useOpenBrowser } from "../cli/use-open-browser.js";
|
|
11
12
|
import { useTunnel } from "../cli/use-tunnel.js";
|
|
12
13
|
import { useTypeScriptCheck } from "../cli/use-typescript-check.js";
|
|
13
|
-
import { scanAndWriteViewsDts } from "../
|
|
14
|
+
import { scanAndWriteViewsDts } from "../views/index.js";
|
|
14
15
|
export default class Dev extends Command {
|
|
15
16
|
static description = "Start development server";
|
|
16
17
|
static examples = ["skybridge"];
|
|
@@ -34,6 +35,10 @@ export default class Dev extends Command {
|
|
|
34
35
|
description: "Show tunnel logs",
|
|
35
36
|
default: false,
|
|
36
37
|
}),
|
|
38
|
+
plain: Flags.boolean({
|
|
39
|
+
description: "Disable the interactive UI and stream raw server logs to stdout, so you can pipe them through a formatter (e.g. `skybridge dev --plain | bunyan`).",
|
|
40
|
+
default: false,
|
|
41
|
+
}),
|
|
37
42
|
};
|
|
38
43
|
async run() {
|
|
39
44
|
const { flags } = await this.parse(Dev);
|
|
@@ -44,7 +49,7 @@ export default class Dev extends Command {
|
|
|
44
49
|
// and the dev UI reports phantom TS errors forever.
|
|
45
50
|
const root = process.cwd();
|
|
46
51
|
try {
|
|
47
|
-
scanAndWriteViewsDts(root, await
|
|
52
|
+
scanAndWriteViewsDts(root, (await resolveSkybridgeConfig(root)).viewsDir);
|
|
48
53
|
}
|
|
49
54
|
catch {
|
|
50
55
|
// Best-effort: if the scan fails (e.g. broken vite config, duplicate
|
|
@@ -61,6 +66,33 @@ export default class Dev extends Command {
|
|
|
61
66
|
__PORT: String(port),
|
|
62
67
|
__TUNNEL_CONTROL_PORT: String(controlPort),
|
|
63
68
|
};
|
|
69
|
+
if (flags.plain) {
|
|
70
|
+
const teardown = runPlain({
|
|
71
|
+
env,
|
|
72
|
+
port,
|
|
73
|
+
fallback,
|
|
74
|
+
version: this.config.version,
|
|
75
|
+
tunnel: flags.tunnel,
|
|
76
|
+
tunnelManager,
|
|
77
|
+
});
|
|
78
|
+
// Synchronous-first shutdown: kill the alpic subprocess up front so we
|
|
79
|
+
// can't leave it orphaned even if another SIGINT listener (e.g.
|
|
80
|
+
// nodemon's) exits the process before our async cleanup completes.
|
|
81
|
+
const shutdown = (code) => () => {
|
|
82
|
+
tunnelManager.stop();
|
|
83
|
+
teardown();
|
|
84
|
+
void closeTunnelControl()
|
|
85
|
+
.catch((err) => {
|
|
86
|
+
console.error("Failed to close tunnel control server", err);
|
|
87
|
+
})
|
|
88
|
+
.finally(() => {
|
|
89
|
+
process.exit(code);
|
|
90
|
+
});
|
|
91
|
+
};
|
|
92
|
+
process.once("SIGINT", shutdown(130));
|
|
93
|
+
process.once("SIGTERM", shutdown(143));
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
64
96
|
const App = () => {
|
|
65
97
|
const tsErrors = useTypeScriptCheck();
|
|
66
98
|
const [messages, pushMessage] = useMessages();
|
package/dist/commands/dev.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,GAAG,EAAE,MAAM,EA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AAO,CAAC,IAAI,GAAQ,CAC5B,IAVO,OAAO,CAAC,EAAE,CAWd,CACP,CAAC,IACE,CACP,IACG,CACP,CAAC;QACJ,CAAC,CAAC;QAEF,sEAAsE;QACtE,yEAAyE;QACzE,yEAAyE;QACzE,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAC,GAAG,KAAG,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QAExE,uEAAuE;QACvE,2EAA2E;QAC3E,wDAAwD;QACxD,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,EAAE;YACtC,aAAa,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,kBAAkB,EAAE;iBACtB,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,GAAG,CAAC,CAAC;YAC9D,CAAC,CAAC;iBACD,OAAO,CAAC,GAAG,EAAE;gBACZ,GAAG,CAAC,OAAO,EAAE,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC","sourcesContent":["import { Command, Flags } from \"@oclif/core\";\nimport { Box, render, Text } from \"ink\";\nimport { resolvePort } from \"../cli/detect-port.js\";\nimport { Header } from \"../cli/header.js\";\nimport { resolveViewsDir } from \"../cli/resolve-views-dir.js\";\nimport { startTunnelControlServer } from \"../cli/tunnel-control-server.js\";\nimport { useMessages } from \"../cli/use-messages.js\";\nimport { useNodemon } from \"../cli/use-nodemon.js\";\nimport { useOpenBrowser } from \"../cli/use-open-browser.js\";\nimport { useTunnel } from \"../cli/use-tunnel.js\";\nimport { useTypeScriptCheck } from \"../cli/use-typescript-check.js\";\nimport { scanAndWriteViewsDts } from \"../web/plugin/scan-views.js\";\n\nexport default class Dev extends Command {\n static override description = \"Start development server\";\n static override examples = [\"skybridge\"];\n static override flags = {\n port: Flags.integer({\n char: \"p\",\n description: \"Port to run the server on\",\n min: 1,\n }),\n tunnel: Flags.boolean({\n description: \"Open an Alpic tunnel for remote testing\",\n default: false,\n }),\n open: Flags.boolean({\n description: \"Open DevTools in the browser when the server is ready\",\n default: process.env.SKYBRIDGE_OPEN !== \"false\",\n allowNo: true,\n }),\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Show tunnel logs\",\n default: false,\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(Dev);\n\n // Generate .skybridge/views.d.ts before render() spawns `tsc --noEmit\n // --watch`. Vite's plugin config hook writes the same file when nodemon\n // boots the server, but tsc starts in parallel — if .skybridge/ doesn't\n // exist at tsc startup, its watcher never picks up the late-created file\n // and the dev UI reports phantom TS errors forever.\n const root = process.cwd();\n try {\n scanAndWriteViewsDts(root, await resolveViewsDir(root));\n } catch {\n // Best-effort: if the scan fails (e.g. broken vite config, duplicate\n // view names) tsc may show phantom errors, but the dev server should\n // still start so the developer can fix the underlying issue.\n }\n\n const { port, fallback, envWarning } = await resolvePort(flags.port);\n if (envWarning) {\n this.warn(envWarning);\n }\n\n const {\n port: controlPort,\n manager: tunnelManager,\n close: closeTunnelControl,\n } = await startTunnelControlServer(() => port);\n\n const env = {\n ...process.env,\n __PORT: String(port),\n __TUNNEL_CONTROL_PORT: String(controlPort),\n };\n\n const App = () => {\n const tsErrors = useTypeScriptCheck();\n const [messages, pushMessage] = useMessages();\n useNodemon(env, pushMessage);\n useOpenBrowser(port, flags.open);\n const tunnelState = useTunnel(\n port,\n pushMessage,\n flags.verbose,\n flags.tunnel,\n );\n\n return (\n <Box flexDirection=\"column\" padding={1} marginLeft={1}>\n <Header version={this.config.version} />\n\n <Box>\n <Text>🏠{\" \"}</Text>\n {fallback ? (\n <Text color=\"yellow\">3000 in use, running on </Text>\n ) : (\n <Text>Running on </Text>\n )}\n <Text color=\"green\">{`http://localhost:${port}/mcp`}</Text>\n </Box>\n <Box marginBottom={1}>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"white\" bold>\n Test locally with DevTools:{\" \"}\n </Text>\n <Text color=\"green\">{`http://localhost:${port}/`}</Text>\n </Box>\n\n {tunnelState.status === \"idle\" && (\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text>Get a public URL and LLM Playground access with </Text>\n <Text color=\"cyan\" bold>\n --tunnel\n </Text>\n <Text>.</Text>\n </Box>\n )}\n {tunnelState.status === \"starting\" && (\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text color=\"yellow\">{tunnelState.message}</Text>\n </Box>\n )}\n {tunnelState.status === \"connected\" && (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text>Exposed on </Text>\n <Text color=\"green\">{`${tunnelState.url}/mcp`}</Text>\n </Box>\n <Box>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"white\" bold>\n Test with an LLM on Playground:{\" \"}\n </Text>\n <Text color=\"green\">{`${tunnelState.url}/try`}</Text>\n </Box>\n </Box>\n )}\n {tunnelState.status === \"error\" && (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text color=\"red\">\n Cannot open tunnel: {tunnelState.message}\n </Text>\n </Box>\n <Box>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"red\">{`Try manually: npx alpic tunnel --port ${port}`}</Text>\n </Box>\n </Box>\n )}\n\n <Box>\n <Text>🛟{\" \"}</Text>\n <Text>Need help? Reach us on </Text>\n <Text color=\"white\" underline>\n https://discord.alpic.ai\n </Text>\n </Box>\n\n {tsErrors.length > 0 && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"red\" bold>\n ⚠️ TypeScript errors found:\n </Text>\n {tsErrors.map((error) => (\n <Box\n key={`${error.file}:${error.line}:${error.col}`}\n marginLeft={2}\n flexDirection=\"column\"\n >\n <Box>\n <Text color=\"white\">{error.file}</Text>\n <Text color=\"grey\">\n ({error.line},{error.col}):{\" \"}\n </Text>\n </Box>\n <Box marginLeft={2}>\n <Text color=\"red\">{error.message}</Text>\n </Box>\n </Box>\n ))}\n </Box>\n )}\n {messages.length > 0 && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"white\" bold>\n Logs:\n </Text>\n {messages.map((message) => (\n <Box key={message.id} marginLeft={2}>\n {message.type === \"restart\" ? (\n <>\n <Text color=\"green\">✓{\" \"}</Text>\n <Text color=\"white\">{message.text}</Text>\n </>\n ) : message.type === \"error\" ? (\n <Text color=\"red\">{message.text}</Text>\n ) : (\n <Text>{message.text}</Text>\n )}\n </Box>\n ))}\n </Box>\n )}\n </Box>\n );\n };\n\n // Note: `exitOnCtrlC: false` because we own SIGINT below to guarantee\n // alpic gets killed before we exit. If anything ever calls `useInput` or\n // puts stdin into raw mode, also wire an explicit `\\x03` keypress to the\n // shutdown function — Ink will otherwise swallow Ctrl-C without ever\n // delivering SIGINT.\n const ink = render(<App />, { exitOnCtrlC: false, patchConsole: true });\n\n // Synchronous-first shutdown: kill the alpic subprocess up front so we\n // can't leave it orphaned even if another SIGINT listener (e.g. nodemon's)\n // exits the process before our async cleanup completes.\n const shutdown = (code: number) => () => {\n tunnelManager.stop();\n void closeTunnelControl()\n .catch((err) => {\n console.error(\"Failed to close tunnel control server\", err);\n })\n .finally(() => {\n ink.unmount();\n process.exit(code);\n });\n };\n process.once(\"SIGINT\", shutdown(130));\n process.once(\"SIGTERM\", shutdown(143));\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"dev.js","sourceRoot":"","sources":["../../src/commands/dev.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aA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QACtE,yEAAyE;QACzE,yEAAyE;QACzE,qEAAqE;QACrE,qBAAqB;QACrB,MAAM,GAAG,GAAG,MAAM,CAAC,KAAC,GAAG,KAAG,EAAE,EAAE,WAAW,EAAE,KAAK,EAAE,YAAY,EAAE,IAAI,EAAE,CAAC,CAAC;QAExE,uEAAuE;QACvE,2EAA2E;QAC3E,wDAAwD;QACxD,MAAM,QAAQ,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,EAAE;YACtC,aAAa,CAAC,IAAI,EAAE,CAAC;YACrB,KAAK,kBAAkB,EAAE;iBACtB,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;gBACb,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,GAAG,CAAC,CAAC;YAC9D,CAAC,CAAC;iBACD,OAAO,CAAC,GAAG,EAAE;gBACZ,GAAG,CAAC,OAAO,EAAE,CAAC;gBACd,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACrB,CAAC,CAAC,CAAC;QACP,CAAC,CAAC;QACF,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;QACtC,OAAO,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC","sourcesContent":["import { Command, Flags } from \"@oclif/core\";\nimport { Box, render, Text } from \"ink\";\nimport { resolvePort } from \"../cli/detect-port.js\";\nimport { Header } from \"../cli/header.js\";\nimport { resolveSkybridgeConfig } from \"../cli/resolve-skybridge-config.js\";\nimport { runPlain } from \"../cli/run-plain.js\";\nimport { startTunnelControlServer } from \"../cli/tunnel-control-server.js\";\nimport { useMessages } from \"../cli/use-messages.js\";\nimport { useNodemon } from \"../cli/use-nodemon.js\";\nimport { useOpenBrowser } from \"../cli/use-open-browser.js\";\nimport { useTunnel } from \"../cli/use-tunnel.js\";\nimport { useTypeScriptCheck } from \"../cli/use-typescript-check.js\";\nimport { scanAndWriteViewsDts } from \"../views/index.js\";\n\nexport default class Dev extends Command {\n static override description = \"Start development server\";\n static override examples = [\"skybridge\"];\n static override flags = {\n port: Flags.integer({\n char: \"p\",\n description: \"Port to run the server on\",\n min: 1,\n }),\n tunnel: Flags.boolean({\n description: \"Open an Alpic tunnel for remote testing\",\n default: false,\n }),\n open: Flags.boolean({\n description: \"Open DevTools in the browser when the server is ready\",\n default: process.env.SKYBRIDGE_OPEN !== \"false\",\n allowNo: true,\n }),\n verbose: Flags.boolean({\n char: \"v\",\n description: \"Show tunnel logs\",\n default: false,\n }),\n plain: Flags.boolean({\n description:\n \"Disable the interactive UI and stream raw server logs to stdout, so you can pipe them through a formatter (e.g. `skybridge dev --plain | bunyan`).\",\n default: false,\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(Dev);\n\n // Generate .skybridge/views.d.ts before render() spawns `tsc --noEmit\n // --watch`. Vite's plugin config hook writes the same file when nodemon\n // boots the server, but tsc starts in parallel — if .skybridge/ doesn't\n // exist at tsc startup, its watcher never picks up the late-created file\n // and the dev UI reports phantom TS errors forever.\n const root = process.cwd();\n try {\n scanAndWriteViewsDts(root, (await resolveSkybridgeConfig(root)).viewsDir);\n } catch {\n // Best-effort: if the scan fails (e.g. broken vite config, duplicate\n // view names) tsc may show phantom errors, but the dev server should\n // still start so the developer can fix the underlying issue.\n }\n\n const { port, fallback, envWarning } = await resolvePort(flags.port);\n if (envWarning) {\n this.warn(envWarning);\n }\n\n const {\n port: controlPort,\n manager: tunnelManager,\n close: closeTunnelControl,\n } = await startTunnelControlServer(() => port);\n\n const env = {\n ...process.env,\n __PORT: String(port),\n __TUNNEL_CONTROL_PORT: String(controlPort),\n };\n\n if (flags.plain) {\n const teardown = runPlain({\n env,\n port,\n fallback,\n version: this.config.version,\n tunnel: flags.tunnel,\n tunnelManager,\n });\n\n // Synchronous-first shutdown: kill the alpic subprocess up front so we\n // can't leave it orphaned even if another SIGINT listener (e.g.\n // nodemon's) exits the process before our async cleanup completes.\n const shutdown = (code: number) => () => {\n tunnelManager.stop();\n teardown();\n void closeTunnelControl()\n .catch((err) => {\n console.error(\"Failed to close tunnel control server\", err);\n })\n .finally(() => {\n process.exit(code);\n });\n };\n process.once(\"SIGINT\", shutdown(130));\n process.once(\"SIGTERM\", shutdown(143));\n return;\n }\n\n const App = () => {\n const tsErrors = useTypeScriptCheck();\n const [messages, pushMessage] = useMessages();\n useNodemon(env, pushMessage);\n useOpenBrowser(port, flags.open);\n const tunnelState = useTunnel(\n port,\n pushMessage,\n flags.verbose,\n flags.tunnel,\n );\n\n return (\n <Box flexDirection=\"column\" padding={1} marginLeft={1}>\n <Header version={this.config.version} />\n\n <Box>\n <Text>🏠{\" \"}</Text>\n {fallback ? (\n <Text color=\"yellow\">3000 in use, running on </Text>\n ) : (\n <Text>Running on </Text>\n )}\n <Text color=\"green\">{`http://localhost:${port}/mcp`}</Text>\n </Box>\n <Box marginBottom={1}>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"white\" bold>\n Test locally with DevTools:{\" \"}\n </Text>\n <Text color=\"green\">{`http://localhost:${port}/`}</Text>\n </Box>\n\n {tunnelState.status === \"idle\" && (\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text>Get a public URL and LLM Playground access with </Text>\n <Text color=\"cyan\" bold>\n --tunnel\n </Text>\n <Text>.</Text>\n </Box>\n )}\n {tunnelState.status === \"starting\" && (\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text color=\"yellow\">{tunnelState.message}</Text>\n </Box>\n )}\n {tunnelState.status === \"connected\" && (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text>Exposed on </Text>\n <Text color=\"green\">{`${tunnelState.url}/mcp`}</Text>\n </Box>\n <Box>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"white\" bold>\n Test with an LLM on Playground:{\" \"}\n </Text>\n <Text color=\"green\">{`${tunnelState.url}/try`}</Text>\n </Box>\n </Box>\n )}\n {tunnelState.status === \"error\" && (\n <Box flexDirection=\"column\" marginBottom={1}>\n <Box>\n <Text>🌍{\" \"}</Text>\n <Text color=\"red\">\n Cannot open tunnel: {tunnelState.message}\n </Text>\n </Box>\n <Box>\n <Text color=\"#20a832\">→{\" \"}</Text>\n <Text color=\"red\">{`Try manually: npx alpic tunnel --port ${port}`}</Text>\n </Box>\n </Box>\n )}\n\n <Box>\n <Text>🛟{\" \"}</Text>\n <Text>Need help? Reach us on </Text>\n <Text color=\"white\" underline>\n https://discord.alpic.ai\n </Text>\n </Box>\n\n {tsErrors.length > 0 && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"red\" bold>\n ⚠️ TypeScript errors found:\n </Text>\n {tsErrors.map((error) => (\n <Box\n key={`${error.file}:${error.line}:${error.col}`}\n marginLeft={2}\n flexDirection=\"column\"\n >\n <Box>\n <Text color=\"white\">{error.file}</Text>\n <Text color=\"grey\">\n ({error.line},{error.col}):{\" \"}\n </Text>\n </Box>\n <Box marginLeft={2}>\n <Text color=\"red\">{error.message}</Text>\n </Box>\n </Box>\n ))}\n </Box>\n )}\n {messages.length > 0 && (\n <Box marginTop={1} flexDirection=\"column\">\n <Text color=\"white\" bold>\n Logs:\n </Text>\n {messages.map((message) => (\n <Box key={message.id} marginLeft={2}>\n {message.type === \"restart\" ? (\n <>\n <Text color=\"green\">✓{\" \"}</Text>\n <Text color=\"white\">{message.text}</Text>\n </>\n ) : message.type === \"error\" ? (\n <Text color=\"red\">{message.text}</Text>\n ) : (\n <Text>{message.text}</Text>\n )}\n </Box>\n ))}\n </Box>\n )}\n </Box>\n );\n };\n\n // Note: `exitOnCtrlC: false` because we own SIGINT below to guarantee\n // alpic gets killed before we exit. If anything ever calls `useInput` or\n // puts stdin into raw mode, also wire an explicit `\\x03` keypress to the\n // shutdown function — Ink will otherwise swallow Ctrl-C without ever\n // delivering SIGINT.\n const ink = render(<App />, { exitOnCtrlC: false, patchConsole: true });\n\n // Synchronous-first shutdown: kill the alpic subprocess up front so we\n // can't leave it orphaned even if another SIGINT listener (e.g. nodemon's)\n // exits the process before our async cleanup completes.\n const shutdown = (code: number) => () => {\n tunnelManager.stop();\n void closeTunnelControl()\n .catch((err) => {\n console.error(\"Failed to close tunnel control server\", err);\n })\n .finally(() => {\n ink.unmount();\n process.exit(code);\n });\n };\n process.once(\"SIGINT\", shutdown(130));\n process.once(\"SIGTERM\", shutdown(143));\n }\n}\n"]}
|
package/dist/commands/start.js
CHANGED
|
@@ -20,12 +20,12 @@ export default class Start extends Command {
|
|
|
20
20
|
this.warn(envWarning);
|
|
21
21
|
}
|
|
22
22
|
console.clear();
|
|
23
|
-
// `dist/
|
|
23
|
+
// `dist/index.js` is the natural entry (the user's `await app.run()`
|
|
24
24
|
// binds the port). Prefer `dist/__entry.js` when present because it
|
|
25
25
|
// primes the Vite manifest first — without it, hashed asset URLs in
|
|
26
26
|
// views won't resolve.
|
|
27
27
|
const entryPath = resolve(process.cwd(), "dist/__entry.js");
|
|
28
|
-
const fallbackPath = resolve(process.cwd(), "dist/
|
|
28
|
+
const fallbackPath = resolve(process.cwd(), "dist/index.js");
|
|
29
29
|
const indexPath = existsSync(entryPath) ? entryPath : fallbackPath;
|
|
30
30
|
if (!existsSync(indexPath)) {
|
|
31
31
|
console.error("❌ Error: No build output found");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"start.js","sourceRoot":"","sources":["../../src/commands/start.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,uBAAuB,CAAC;AAEnD,MAAM,CAAC,OAAO,OAAO,KAAM,SAAQ,OAAO;IACxC,MAAM,CAAU,W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,CAAC;QACJ,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,GAAG,CAAC,uCAAuC,IAAI,aAAa,CAAC,CAAC;QACxE,CAAC;QAED,MAAM,UAAU,CAAC,QAAQ,SAAS,EAAE,EAAE;YACpC,KAAK,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,SAAS,CAAC;YACvC,GAAG,EAAE;gBACH,GAAG,OAAO,CAAC,GAAG;gBACd,QAAQ,EAAE,YAAY;gBACtB,MAAM,EAAE,MAAM,CAAC,IAAI,CAAC;aACrB;SACF,CAAC,CAAC;IACL,CAAC","sourcesContent":["import { existsSync } from \"node:fs\";\nimport { resolve } from \"node:path\";\nimport { Command, Flags } from \"@oclif/core\";\nimport { resolvePort } from \"../cli/detect-port.js\";\nimport { runCommand } from \"../cli/run-command.js\";\n\nexport default class Start extends Command {\n static override description = \"Start production server\";\n static override examples = [\"skybridge start\"];\n static override flags = {\n port: Flags.integer({\n char: \"p\",\n description: \"Port to run the server on\",\n min: 1,\n }),\n };\n\n public async run(): Promise<void> {\n const { flags } = await this.parse(Start);\n const { port, fallback, envWarning } = await resolvePort(flags.port);\n if (envWarning) {\n this.warn(envWarning);\n }\n\n console.clear();\n\n // `dist/index.js` is the natural entry (the user's `await app.run()`\n // binds the port). Prefer `dist/__entry.js` when present because it\n // primes the Vite manifest first — without it, hashed asset URLs in\n // views won't resolve.\n const entryPath = resolve(process.cwd(), \"dist/__entry.js\");\n const fallbackPath = resolve(process.cwd(), \"dist/index.js\");\n const indexPath = existsSync(entryPath) ? entryPath : fallbackPath;\n\n if (!existsSync(indexPath)) {\n console.error(\"❌ Error: No build output found\");\n console.error(\"\");\n console.error(\"Please build your project first:\");\n console.error(\" skybridge build\");\n console.error(\"\");\n process.exit(1);\n }\n\n console.log(\n `\\x1b[36m\\x1b[1m⛰ Skybridge\\x1b[0m \\x1b[36mv${this.config.version}\\x1b[0m`,\n );\n if (fallback) {\n console.log(\n `\\x1b[33m3000 in use, running on\\x1b[0m \\x1b[32mhttp://localhost:${port}/mcp\\x1b[0m`,\n );\n } else {\n console.log(`Running on \\x1b[32mhttp://localhost:${port}/mcp\\x1b[0m`);\n }\n\n await runCommand(`node ${indexPath}`, {\n stdio: [\"ignore\", \"inherit\", \"inherit\"],\n env: {\n ...process.env,\n NODE_ENV: \"production\",\n __PORT: String(port),\n },\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export declare const TOOL_OUTPUT_WARNING_TOKENS = 5000;
|
|
2
|
+
export declare const VIEW_STATE_WARNING_TOKENS = 20000;
|
|
3
|
+
export declare function estimateContextTokens(value: unknown): number;
|
|
4
|
+
export declare function warnOnLargeToolOutput(result: unknown, toolName: string): void;
|
|
5
|
+
export declare function warnOnLargeViewState(value: unknown, source: string): void;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
export const TOOL_OUTPUT_WARNING_TOKENS = 5_000;
|
|
2
|
+
export const VIEW_STATE_WARNING_TOKENS = 20_000;
|
|
3
|
+
export function estimateContextTokens(value) {
|
|
4
|
+
try {
|
|
5
|
+
const serialized = JSON.stringify(value);
|
|
6
|
+
if (!serialized) {
|
|
7
|
+
return 0;
|
|
8
|
+
}
|
|
9
|
+
return Math.ceil(new TextEncoder().encode(serialized).length / 4);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return 0;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
export function warnOnLargeToolOutput(result, toolName) {
|
|
16
|
+
if (!result || typeof result !== "object" || Array.isArray(result)) {
|
|
17
|
+
return;
|
|
18
|
+
}
|
|
19
|
+
const { _meta, ...modelVisibleResult } = result;
|
|
20
|
+
const tokenCount = estimateContextTokens(modelVisibleResult);
|
|
21
|
+
if (tokenCount >= TOOL_OUTPUT_WARNING_TOKENS) {
|
|
22
|
+
console.warn(`[skybridge] Tool "${toolName}" returned ${tokenCount} estimated model-visible tokens; this reaches the ${TOOL_OUTPUT_WARNING_TOKENS}-token warning threshold and may overload model context. Content and structured content are included in this estimate.`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
export function warnOnLargeViewState(value, source) {
|
|
26
|
+
const tokenCount = estimateContextTokens(value);
|
|
27
|
+
if (tokenCount >= VIEW_STATE_WARNING_TOKENS) {
|
|
28
|
+
console.warn(`[skybridge] ${source} is persisting ${tokenCount} estimated tokens in model-visible view state; this reaches the ${VIEW_STATE_WARNING_TOKENS}-token warning threshold and may overload model context. Persisted view state and data-llm context are included in this estimate.`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=context-warnings.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-warnings.js","sourceRoot":"","sources":["../src/context-warnings.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,KAAK,CAAC;AAChD,MAAM,CAAC,MAAM,yBAAyB,GAAG,MAAM,CAAC;AAEhD,MAAM,UAAU,qBAAqB,CAAC,KAAc;IAClD,IAAI,CAAC;QACH,MAAM,UAAU,GAAG,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;QACzC,IAAI,CAAC,UAAU,EAAE,CAAC;YAChB,OAAO,CAAC,CAAC;QACX,CAAC;QACD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACpE,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,CAAC,CAAC;IACX,CAAC;AACH,CAAC;AAED,MAAM,UAAU,qBAAqB,CAAC,MAAe,EAAE,QAAgB;IACrE,IAAI,CAAC,MAAM,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;QACnE,OAAO;IACT,CAAC;IACD,MAAM,EAAE,KAAK,EAAE,GAAG,kBAAkB,EAAE,GAAG,MAAiC,CAAC;IAC3E,MAAM,UAAU,GAAG,qBAAqB,CAAC,kBAAkB,CAAC,CAAC;IAC7D,IAAI,UAAU,IAAI,0BAA0B,EAAE,CAAC;QAC7C,OAAO,CAAC,IAAI,CACV,qBAAqB,QAAQ,cAAc,UAAU,qDAAqD,0BAA0B,wHAAwH,CAC7P,CAAC;IACJ,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,KAAc,EAAE,MAAc;IACjE,MAAM,UAAU,GAAG,qBAAqB,CAAC,KAAK,CAAC,CAAC;IAChD,IAAI,UAAU,IAAI,yBAAyB,EAAE,CAAC;QAC5C,OAAO,CAAC,IAAI,CACV,eAAe,MAAM,kBAAkB,UAAU,mEAAmE,yBAAyB,mIAAmI,CACjR,CAAC;IACJ,CAAC;AACH,CAAC","sourcesContent":["export const TOOL_OUTPUT_WARNING_TOKENS = 5_000;\nexport const VIEW_STATE_WARNING_TOKENS = 20_000;\n\nexport function estimateContextTokens(value: unknown): number {\n try {\n const serialized = JSON.stringify(value);\n if (!serialized) {\n return 0;\n }\n return Math.ceil(new TextEncoder().encode(serialized).length / 4);\n } catch {\n return 0;\n }\n}\n\nexport function warnOnLargeToolOutput(result: unknown, toolName: string): void {\n if (!result || typeof result !== \"object\" || Array.isArray(result)) {\n return;\n }\n const { _meta, ...modelVisibleResult } = result as Record<string, unknown>;\n const tokenCount = estimateContextTokens(modelVisibleResult);\n if (tokenCount >= TOOL_OUTPUT_WARNING_TOKENS) {\n console.warn(\n `[skybridge] Tool \"${toolName}\" returned ${tokenCount} estimated model-visible tokens; this reaches the ${TOOL_OUTPUT_WARNING_TOKENS}-token warning threshold and may overload model context. Content and structured content are included in this estimate.`,\n );\n }\n}\n\nexport function warnOnLargeViewState(value: unknown, source: string): void {\n const tokenCount = estimateContextTokens(value);\n if (tokenCount >= VIEW_STATE_WARNING_TOKENS) {\n console.warn(\n `[skybridge] ${source} is persisting ${tokenCount} estimated tokens in model-visible view state; this reaches the ${VIEW_STATE_WARNING_TOKENS}-token warning threshold and may overload model context. Persisted view state and data-llm context are included in this estimate.`,\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { estimateContextTokens, TOOL_OUTPUT_WARNING_TOKENS, warnOnLargeToolOutput, } from "./context-warnings.js";
|
|
3
|
+
describe("context warnings", () => {
|
|
4
|
+
it("estimates UTF-8 bytes and returns zero for no content", () => {
|
|
5
|
+
expect(estimateContextTokens("é")).toBe(1);
|
|
6
|
+
expect(estimateContextTokens(undefined)).toBe(0);
|
|
7
|
+
});
|
|
8
|
+
it("warns when model-visible tool output reaches the threshold", () => {
|
|
9
|
+
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => { });
|
|
10
|
+
warnOnLargeToolOutput({
|
|
11
|
+
content: [
|
|
12
|
+
{
|
|
13
|
+
type: "text",
|
|
14
|
+
text: "x".repeat(TOOL_OUTPUT_WARNING_TOKENS * 4),
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
}, "large-output");
|
|
18
|
+
expect(warnSpy).toHaveBeenCalledWith(expect.stringContaining('Tool "large-output" returned'));
|
|
19
|
+
warnSpy.mockRestore();
|
|
20
|
+
});
|
|
21
|
+
it("does not warn for large metadata", () => {
|
|
22
|
+
const warnSpy = vi.spyOn(console, "warn").mockImplementation(() => { });
|
|
23
|
+
warnOnLargeToolOutput({ content: [], _meta: { private: "x".repeat(100_000) } }, "large-meta");
|
|
24
|
+
expect(warnSpy).not.toHaveBeenCalled();
|
|
25
|
+
warnSpy.mockRestore();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
//# sourceMappingURL=context-warnings.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-warnings.test.js","sourceRoot":"","sources":["../src/context-warnings.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,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AAC,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QACvC,OAAO,CAAC,WAAW,EAAE,CAAC;IACxB,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC","sourcesContent":["import { describe, expect, it, vi } from \"vitest\";\nimport {\n estimateContextTokens,\n TOOL_OUTPUT_WARNING_TOKENS,\n warnOnLargeToolOutput,\n} from \"./context-warnings.js\";\n\ndescribe(\"context warnings\", () => {\n it(\"estimates UTF-8 bytes and returns zero for no content\", () => {\n expect(estimateContextTokens(\"é\")).toBe(1);\n expect(estimateContextTokens(undefined)).toBe(0);\n });\n\n it(\"warns when model-visible tool output reaches the threshold\", () => {\n const warnSpy = vi.spyOn(console, \"warn\").mockImplementation(() => {});\n\n warnOnLargeToolOutput(\n {\n content: [\n {\n type: \"text\",\n text: \"x\".repeat(TOOL_OUTPUT_WARNING_TOKENS * 4),\n },\n ],\n },\n \"large-output\",\n );\n\n expect(warnSpy).toHaveBeenCalledWith(\n expect.stringContaining('Tool \"large-output\" returned'),\n );\n warnSpy.mockRestore();\n });\n\n it(\"does not warn for large metadata\", () => {\n const warnSpy = vi.spyOn(console, \"warn\").mockImplementation(() => {});\n\n warnOnLargeToolOutput(\n { content: [], _meta: { private: \"x\".repeat(100_000) } },\n \"large-meta\",\n );\n\n expect(warnSpy).not.toHaveBeenCalled();\n warnSpy.mockRestore();\n });\n});\n"]}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import type { Implementation, Server as SdkServer, ServerOptions } from "@modelcontextprotocol/server";
|
|
2
|
+
import type { ErrorRequestHandler, Express, RequestHandler } from "express";
|
|
3
|
+
import type { OAuthConfig, OAuthProvider } from "./auth/index.js";
|
|
4
|
+
import type { ExtraClaims } from "./auth.js";
|
|
5
|
+
import { type JsonOptions, McpServer, type McpServerTypes, type ToolDef } from "./server.js";
|
|
6
|
+
/**
|
|
7
|
+
* The `handler` field of {@link SkybridgeConfig}: builds the app's MCP
|
|
8
|
+
* surface. Runs again for **every incoming request**, on a fresh
|
|
9
|
+
* {@link McpServer}, so keep it to registration: pools, clients and any other
|
|
10
|
+
* one-time work belong in `setup`, whose result is the second argument. It
|
|
11
|
+
* must **return** the chained server so `typeof app` carries the registered
|
|
12
|
+
* tool types.
|
|
13
|
+
*
|
|
14
|
+
* @typeParam TConfig - What `setup` resolved to, passed as the second argument.
|
|
15
|
+
*/
|
|
16
|
+
export type SkybridgeHandler<TTools extends Record<string, ToolDef>, TConfig, TAuthExtra extends ExtraClaims> = (server: McpServer<Record<never, ToolDef>, TAuthExtra>, config: TConfig) => McpServer<TTools, TAuthExtra>;
|
|
17
|
+
/**
|
|
18
|
+
* What the `oauth` field accepts: an {@link OAuthConfig}, a provider
|
|
19
|
+
* (`oauth: auth0Provider(...)`), or a function of the `setup` result returning
|
|
20
|
+
* either. Providers and functions resolve once, at {@link Skybridge.run} or on
|
|
21
|
+
* the first request, never at module import. Anything asynchronous belongs in
|
|
22
|
+
* a provider's `resolve`.
|
|
23
|
+
*/
|
|
24
|
+
export type SkybridgeOAuthInput<TConfig, TExtra extends ExtraClaims> = OAuthConfig<TExtra> | OAuthProvider<TExtra> | ((config: TConfig) => OAuthConfig<TExtra> | OAuthProvider<TExtra>);
|
|
25
|
+
/**
|
|
26
|
+
* Everything a Skybridge app needs in one bag: the MCP implementation info
|
|
27
|
+
* (`name`, `version`, …), the SDK's {@link ServerOptions} (`capabilities`,
|
|
28
|
+
* `instructions`, …), the Express and skills options, and the app's behavior
|
|
29
|
+
* (`setup`, `oauth`, `handler`).
|
|
30
|
+
*
|
|
31
|
+
* All type parameters are inferred from the value: the config from `setup`,
|
|
32
|
+
* the auth claims from `oauth`, and the tool registry from the server
|
|
33
|
+
* `handler` returns.
|
|
34
|
+
*/
|
|
35
|
+
export type SkybridgeConfig<TTools extends Record<string, ToolDef> = Record<never, ToolDef>, TConfig = undefined, TAuthExtra extends ExtraClaims = ExtraClaims> = Implementation & ServerOptions & {
|
|
36
|
+
/** Options for the built-in `express.json()` middleware, e.g. `{ limit: "10mb" }`. */
|
|
37
|
+
json?: JsonOptions;
|
|
38
|
+
/**
|
|
39
|
+
* @experimental Serve Agent Skills from `src/skills` over MCP (SEP-2640).
|
|
40
|
+
* API may change.
|
|
41
|
+
*/
|
|
42
|
+
skills?: boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Loads whatever the app needs up front (remote config, secrets, datasets,
|
|
45
|
+
* …). Runs **once** — at {@link Skybridge.run} or on the first request,
|
|
46
|
+
* never at module import — and its awaited return value is passed to an
|
|
47
|
+
* `oauth` function and to `handler` as the second argument.
|
|
48
|
+
*/
|
|
49
|
+
setup?: () => TConfig;
|
|
50
|
+
/**
|
|
51
|
+
* Resource-server OAuth. When set, mounts the well-known metadata routes
|
|
52
|
+
* and bearer auth on `/mcp`, and the verifier's claims type
|
|
53
|
+
* `extra.http.authInfo.extra` in tool handlers.
|
|
54
|
+
*/
|
|
55
|
+
oauth?: SkybridgeOAuthInput<Awaited<TConfig>, TAuthExtra>;
|
|
56
|
+
/** Registers the MCP surface, per request. See {@link SkybridgeHandler}. */
|
|
57
|
+
handler: SkybridgeHandler<TTools, Awaited<TConfig>, TAuthExtra>;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* A Skybridge app: the HTTP surface (Express, OAuth metadata, the `/mcp`
|
|
61
|
+
* route) plus a handler that builds the MCP server for each request.
|
|
62
|
+
*
|
|
63
|
+
* The handler runs for every request, so tools, resources, prompts and views
|
|
64
|
+
* are always registered on the instance that serves the request. Anything in
|
|
65
|
+
* the handler body other than registration therefore runs per request too.
|
|
66
|
+
* Anything asynchronous the app needs (remote config, secrets, …) goes in
|
|
67
|
+
* `setup`, which runs once and feeds the handler's second argument.
|
|
68
|
+
*
|
|
69
|
+
* @example
|
|
70
|
+
* ```ts
|
|
71
|
+
* export const app = new Skybridge({
|
|
72
|
+
* name: "my-app",
|
|
73
|
+
* version: "1.0.0",
|
|
74
|
+
* setup: async () => loadConfig(),
|
|
75
|
+
* oauth: (config) => descopeProvider({ url: config.mcpServerUrl }),
|
|
76
|
+
* handler: (server, config) =>
|
|
77
|
+
* server.registerTool(
|
|
78
|
+
* {
|
|
79
|
+
* name: "search",
|
|
80
|
+
* inputSchema: { query: z.string() },
|
|
81
|
+
* view: { component: "search" },
|
|
82
|
+
* },
|
|
83
|
+
* async ({ query }) => ({ content: `Results for ${query}` }),
|
|
84
|
+
* ),
|
|
85
|
+
* });
|
|
86
|
+
*
|
|
87
|
+
* export type AppType = typeof app;
|
|
88
|
+
* ```
|
|
89
|
+
*
|
|
90
|
+
* @see https://docs.skybridge.tech/api-reference/mcp-server
|
|
91
|
+
*/
|
|
92
|
+
export declare class Skybridge<TTools extends Record<string, ToolDef> = Record<never, ToolDef>, TConfig = undefined, TAuthExtra extends ExtraClaims = ExtraClaims> {
|
|
93
|
+
readonly $types: McpServerTypes<TTools>;
|
|
94
|
+
private readonly serverInfo;
|
|
95
|
+
private readonly serverOptions;
|
|
96
|
+
private readonly skills?;
|
|
97
|
+
private oauthEnabled;
|
|
98
|
+
private readonly handler;
|
|
99
|
+
private readonly setup?;
|
|
100
|
+
private readonly oauthInput?;
|
|
101
|
+
private config?;
|
|
102
|
+
private readonly expressApp;
|
|
103
|
+
private readonly errorMiddleware;
|
|
104
|
+
private readonly monitoringEntry;
|
|
105
|
+
private resolveResourceMetadataUrl?;
|
|
106
|
+
private readyPromise?;
|
|
107
|
+
private slowHandlerWarned;
|
|
108
|
+
constructor({ name, title, version, description, icons, websiteUrl, json, skills, setup, oauth, handler, ...serverOptions }: SkybridgeConfig<TTools, TConfig, TAuthExtra>);
|
|
109
|
+
/**
|
|
110
|
+
* Resolve `setup` and `oauth`, then wire OAuth onto the Express app. Runs
|
|
111
|
+
* once; every entry point that needs a built server awaits it, and a failed
|
|
112
|
+
* attempt is retried on the next call.
|
|
113
|
+
*
|
|
114
|
+
* @internal
|
|
115
|
+
*/
|
|
116
|
+
ready(): Promise<void>;
|
|
117
|
+
/**
|
|
118
|
+
* The underlying Express app. Use this to extend the HTTP server with
|
|
119
|
+
* custom routes, middleware, or settings — e.g.
|
|
120
|
+
* `app.express.get("/health", ...)`.
|
|
121
|
+
*
|
|
122
|
+
* `express.json()` is pre-applied — tune it via the `json` config field,
|
|
123
|
+
* e.g. `new Skybridge({ name, version, json: { limit: "10mb" }, handler })`.
|
|
124
|
+
* Register your handlers before `run()`; after `run()`, dev-mode middleware,
|
|
125
|
+
* the `/mcp` route, and the default error handler are appended in that order.
|
|
126
|
+
*
|
|
127
|
+
* Note: Alpic Cloud only routes traffic to `/mcp` — custom routes work
|
|
128
|
+
* locally and on self-hosted deployments.
|
|
129
|
+
*/
|
|
130
|
+
get express(): Express;
|
|
131
|
+
/**
|
|
132
|
+
* Build a fresh server for one stateless HTTP request, as
|
|
133
|
+
* `createMcpHandler`'s factory contract requires: the handler runs again so
|
|
134
|
+
* the SDK's handler closures belong to the instance whose protocol era it
|
|
135
|
+
* stamps. Sharing one instance's handler maps instead would bind them to an
|
|
136
|
+
* instance that is never marked, pinning every request to the 2025 codec and
|
|
137
|
+
* letting concurrent callers overwrite each other's negotiated version.
|
|
138
|
+
*
|
|
139
|
+
* Awaits `setup` and the `oauth` input on first use.
|
|
140
|
+
*/
|
|
141
|
+
createServerInstance(): Promise<SdkServer>;
|
|
142
|
+
/**
|
|
143
|
+
* Connect a Skybridge app to an MCP transport. Use this when you're
|
|
144
|
+
* embedding Skybridge in a host that already manages its own transport
|
|
145
|
+
* (e.g. stdio for desktop apps); for HTTP, prefer {@link Skybridge.run}
|
|
146
|
+
* which sets the transport up for you.
|
|
147
|
+
*/
|
|
148
|
+
connect(transport: Parameters<SdkServer["connect"]>[0]): Promise<void>;
|
|
149
|
+
/**
|
|
150
|
+
* Register Express middleware on the underlying app. Mirrors `app.use` —
|
|
151
|
+
* pass handlers directly or a path-prefixed handler list. Register before
|
|
152
|
+
* {@link Skybridge.run}; ordering matches Express.
|
|
153
|
+
*
|
|
154
|
+
* Note: Alpic Cloud only routes traffic to `/mcp`. Custom paths work
|
|
155
|
+
* locally and on self-hosted deployments.
|
|
156
|
+
*/
|
|
157
|
+
use(...handlers: RequestHandler[]): this;
|
|
158
|
+
use(path: string, ...handlers: RequestHandler[]): this;
|
|
159
|
+
/**
|
|
160
|
+
* Register Express error-handling middleware to run after the built-in
|
|
161
|
+
* `/mcp` route (or your custom route). Use this to log or transform errors
|
|
162
|
+
* thrown by tool handlers before the default error handler responds.
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* ```ts
|
|
166
|
+
* app.useOnError((err, _req, _res, next) => {
|
|
167
|
+
* logger.error(err);
|
|
168
|
+
* next(err);
|
|
169
|
+
* });
|
|
170
|
+
* ```
|
|
171
|
+
*/
|
|
172
|
+
useOnError(...handlers: ErrorRequestHandler[]): this;
|
|
173
|
+
useOnError(path: string, ...handlers: ErrorRequestHandler[]): this;
|
|
174
|
+
/**
|
|
175
|
+
* Start the HTTP server. Listens on `process.env.__PORT` (default `3000`),
|
|
176
|
+
* mounts the `/mcp` route, and applies any custom Express middleware
|
|
177
|
+
* registered via {@link Skybridge.use} / {@link Skybridge.useOnError}.
|
|
178
|
+
*
|
|
179
|
+
* On Cloudflare Workers / workerd, returns an object exposing `fetch` so
|
|
180
|
+
* the runtime can bridge incoming requests to the Node HTTP server. On
|
|
181
|
+
* Vercel (`VERCEL === "1"`), returns the Express app directly so the
|
|
182
|
+
* serverless function entry can call it as a `(req, res)` handler. On
|
|
183
|
+
* Node, returns `undefined` once listening. When the process was spawned
|
|
184
|
+
* with an IPC channel, the bound port is reported to the parent as
|
|
185
|
+
* `{ type: "skybridge:listening", port }`, the readiness signal test runners
|
|
186
|
+
* wait on instead of polling.
|
|
187
|
+
*/
|
|
188
|
+
run(): Promise<{
|
|
189
|
+
fetch: (...args: unknown[]) => unknown;
|
|
190
|
+
} | Express | undefined>;
|
|
191
|
+
private buildServer;
|
|
192
|
+
private middlewareEntries;
|
|
193
|
+
private instrumentHandlers;
|
|
194
|
+
}
|