skybridge 0.0.0-dev.f9651e4 → 0.0.0-dev.f9ae1d8
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 +24 -16
- package/dist/cli/detect-port.d.ts +18 -0
- package/dist/cli/detect-port.js +61 -0
- package/dist/cli/detect-port.js.map +1 -0
- package/dist/cli/header.js +1 -1
- package/dist/cli/header.js.map +1 -1
- package/dist/cli/types.d.ts +5 -0
- package/dist/cli/types.js +2 -0
- package/dist/cli/types.js.map +1 -0
- package/dist/cli/use-messages.d.ts +3 -0
- package/dist/cli/use-messages.js +11 -0
- package/dist/cli/use-messages.js.map +1 -0
- package/dist/cli/use-nodemon.d.ts +2 -6
- package/dist/cli/use-nodemon.js +8 -13
- package/dist/cli/use-nodemon.js.map +1 -1
- package/dist/cli/use-tunnel.d.ts +14 -0
- package/dist/cli/use-tunnel.js +97 -0
- package/dist/cli/use-tunnel.js.map +1 -0
- package/dist/commands/build.js +28 -7
- package/dist/commands/build.js.map +1 -1
- package/dist/commands/dev.d.ts +3 -1
- package/dist/commands/dev.js +25 -7
- package/dist/commands/dev.js.map +1 -1
- package/dist/commands/start.d.ts +3 -1
- package/dist/commands/start.js +30 -9
- package/dist/commands/start.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.d.ts +5 -6
- package/dist/server/asset-base-url-transform-plugin.js +8 -9
- package/dist/server/asset-base-url-transform-plugin.js.map +1 -1
- package/dist/server/asset-base-url-transform-plugin.test.js +12 -13
- package/dist/server/asset-base-url-transform-plugin.test.js.map +1 -1
- package/dist/server/content-helpers.d.ts +27 -0
- package/dist/server/content-helpers.js +46 -0
- package/dist/server/content-helpers.js.map +1 -0
- package/dist/server/content-helpers.test.js +70 -0
- package/dist/server/content-helpers.test.js.map +1 -0
- package/dist/server/express.d.ts +9 -3
- package/dist/server/express.js +33 -25
- package/dist/server/express.js.map +1 -1
- package/dist/server/express.test.js +227 -12
- package/dist/server/express.test.js.map +1 -1
- package/dist/server/index.d.ts +5 -3
- package/dist/server/index.js +3 -2
- package/dist/server/index.js.map +1 -1
- package/dist/server/inferUtilityTypes.d.ts +6 -6
- package/dist/server/metric.d.ts +14 -0
- package/dist/server/metric.js +62 -0
- package/dist/server/metric.js.map +1 -0
- package/dist/server/middleware.d.ts +124 -0
- package/dist/server/middleware.js +93 -0
- package/dist/server/middleware.js.map +1 -0
- package/dist/server/middleware.test-d.js +75 -0
- package/dist/server/middleware.test-d.js.map +1 -0
- package/dist/server/middleware.test.d.ts +1 -0
- package/dist/server/middleware.test.js +493 -0
- package/dist/server/middleware.test.js.map +1 -0
- package/dist/server/server.d.ts +133 -69
- package/dist/server/server.js +315 -85
- package/dist/server/server.js.map +1 -1
- package/dist/server/templateHelper.d.ts +5 -6
- package/dist/server/templateHelper.js.map +1 -1
- package/dist/server/templates/development.hbs +2 -57
- package/dist/server/templates/production.hbs +1 -1
- package/dist/server/viewsDevServer.d.ts +14 -0
- package/dist/server/viewsDevServer.js +45 -0
- package/dist/server/viewsDevServer.js.map +1 -0
- package/dist/test/utils.d.ts +16 -244
- package/dist/test/utils.js +42 -37
- package/dist/test/utils.js.map +1 -1
- package/dist/test/view.test.d.ts +1 -0
- package/dist/test/view.test.js +523 -0
- package/dist/test/view.test.js.map +1 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +5 -0
- package/dist/version.js.map +1 -0
- package/dist/web/bridges/apps-sdk/adaptor.d.ts +8 -6
- package/dist/web/bridges/apps-sdk/adaptor.js +39 -26
- package/dist/web/bridges/apps-sdk/adaptor.js.map +1 -1
- package/dist/web/bridges/apps-sdk/bridge.d.ts +1 -1
- package/dist/web/bridges/apps-sdk/index.d.ts +1 -1
- package/dist/web/bridges/apps-sdk/index.js.map +1 -1
- package/dist/web/bridges/apps-sdk/types.d.ts +18 -10
- package/dist/web/bridges/apps-sdk/types.js.map +1 -1
- package/dist/web/bridges/mcp-app/adaptor.d.ts +20 -8
- package/dist/web/bridges/mcp-app/adaptor.js +138 -60
- package/dist/web/bridges/mcp-app/adaptor.js.map +1 -1
- package/dist/web/bridges/mcp-app/bridge.d.ts +13 -30
- package/dist/web/bridges/mcp-app/bridge.js +43 -196
- package/dist/web/bridges/mcp-app/bridge.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.d.ts +5 -3
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js +2 -2
- package/dist/web/bridges/mcp-app/use-mcp-app-context.js.map +1 -1
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js +1 -41
- package/dist/web/bridges/mcp-app/use-mcp-app-context.test.js.map +1 -1
- package/dist/web/bridges/types.d.ts +22 -11
- package/dist/web/components/modal-provider.js +3 -5
- package/dist/web/components/modal-provider.js.map +1 -1
- package/dist/web/create-store.js +17 -3
- package/dist/web/create-store.js.map +1 -1
- package/dist/web/create-store.test.js +21 -18
- package/dist/web/create-store.test.js.map +1 -1
- package/dist/web/data-llm.d.ts +1 -1
- package/dist/web/data-llm.js +3 -3
- package/dist/web/data-llm.js.map +1 -1
- package/dist/web/data-llm.test.js +24 -23
- package/dist/web/data-llm.test.js.map +1 -1
- package/dist/web/generate-helpers.d.ts +20 -18
- package/dist/web/generate-helpers.js +20 -18
- package/dist/web/generate-helpers.js.map +1 -1
- package/dist/web/generate-helpers.test-d.js +26 -26
- package/dist/web/generate-helpers.test-d.js.map +1 -1
- package/dist/web/helpers/state.d.ts +2 -2
- package/dist/web/helpers/state.js +11 -11
- package/dist/web/helpers/state.js.map +1 -1
- package/dist/web/helpers/state.test.js +9 -9
- package/dist/web/helpers/state.test.js.map +1 -1
- package/dist/web/hooks/index.d.ts +2 -2
- package/dist/web/hooks/index.js +1 -1
- package/dist/web/hooks/index.js.map +1 -1
- package/dist/web/hooks/test/utils.js +4 -0
- package/dist/web/hooks/test/utils.js.map +1 -1
- package/dist/web/hooks/use-display-mode.d.ts +3 -3
- package/dist/web/hooks/use-display-mode.js.map +1 -1
- package/dist/web/hooks/use-display-mode.test-d.d.ts +1 -0
- package/dist/web/hooks/use-display-mode.test-d.js +8 -0
- package/dist/web/hooks/use-display-mode.test-d.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +2 -1
- package/dist/web/hooks/use-files.js +1 -0
- package/dist/web/hooks/use-files.js.map +1 -1
- package/dist/web/hooks/use-files.test.js +22 -2
- package/dist/web/hooks/use-files.test.js.map +1 -1
- package/dist/web/hooks/use-layout.test.js +3 -3
- package/dist/web/hooks/use-layout.test.js.map +1 -1
- package/dist/web/hooks/use-open-external.d.ts +3 -1
- package/dist/web/hooks/use-open-external.js +1 -1
- package/dist/web/hooks/use-open-external.js.map +1 -1
- package/dist/web/hooks/use-open-external.test.js +26 -11
- package/dist/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/web/hooks/use-request-modal.d.ts +1 -1
- package/dist/web/hooks/use-request-modal.js +4 -4
- package/dist/web/hooks/use-request-modal.js.map +1 -1
- package/dist/web/hooks/use-request-modal.test.js +5 -1
- package/dist/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/web/hooks/use-set-open-in-app-url.test.js +5 -11
- package/dist/web/hooks/use-set-open-in-app-url.test.js.map +1 -1
- package/dist/web/hooks/use-tool-info.test.js +1 -1
- package/dist/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/web/hooks/use-user.js +18 -2
- package/dist/web/hooks/use-user.js.map +1 -1
- package/dist/web/hooks/use-user.test.js +29 -1
- package/dist/web/hooks/use-user.test.js.map +1 -1
- package/dist/web/hooks/use-view-state.d.ts +4 -0
- package/dist/web/hooks/use-view-state.js +32 -0
- package/dist/web/hooks/use-view-state.js.map +1 -0
- package/dist/web/hooks/use-view-state.test.d.ts +1 -0
- package/dist/web/hooks/use-view-state.test.js +177 -0
- package/dist/web/hooks/use-view-state.test.js.map +1 -0
- package/dist/web/index.d.ts +1 -2
- package/dist/web/index.js +1 -2
- package/dist/web/index.js.map +1 -1
- package/dist/web/mount-view.d.ts +1 -0
- package/dist/web/{mount-widget.js → mount-view.js} +2 -2
- package/dist/web/mount-view.js.map +1 -0
- package/dist/web/plugin/plugin.d.ts +4 -1
- package/dist/web/plugin/plugin.js +113 -18
- package/dist/web/plugin/plugin.js.map +1 -1
- package/dist/web/plugin/scan-views.d.ts +8 -0
- package/dist/web/plugin/scan-views.js +70 -0
- package/dist/web/plugin/scan-views.js.map +1 -0
- package/dist/web/plugin/scan-views.test.d.ts +1 -0
- package/dist/web/plugin/scan-views.test.js +67 -0
- package/dist/web/plugin/scan-views.test.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.js +1 -1
- package/dist/web/plugin/transform-data-llm.js.map +1 -1
- package/dist/web/plugin/validate-view.d.ts +1 -0
- package/dist/web/plugin/validate-view.js +9 -0
- package/dist/web/plugin/validate-view.js.map +1 -0
- package/dist/web/plugin/validate-view.test.d.ts +1 -0
- package/dist/web/plugin/validate-view.test.js +24 -0
- package/dist/web/plugin/validate-view.test.js.map +1 -0
- package/package.json +30 -19
- package/tsconfig.base.json +33 -0
- package/dist/server/widgetsDevServer.d.ts +0 -12
- package/dist/server/widgetsDevServer.js +0 -57
- package/dist/server/widgetsDevServer.js.map +0 -1
- package/dist/test/widget.test.js +0 -261
- package/dist/test/widget.test.js.map +0 -1
- package/dist/web/hooks/use-widget-state.d.ts +0 -4
- package/dist/web/hooks/use-widget-state.js +0 -32
- package/dist/web/hooks/use-widget-state.js.map +0 -1
- package/dist/web/hooks/use-widget-state.test.js +0 -62
- package/dist/web/hooks/use-widget-state.test.js.map +0 -1
- package/dist/web/mount-widget.d.ts +0 -1
- package/dist/web/mount-widget.js.map +0 -1
- /package/dist/{test/widget.test.d.ts → server/content-helpers.test.d.ts} +0 -0
- /package/dist/{web/hooks/use-widget-state.test.d.ts → server/middleware.test-d.d.ts} +0 -0
package/README.md
CHANGED
|
@@ -4,11 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
<br />
|
|
6
6
|
|
|
7
|
-
# Skybridge
|
|
8
|
-
|
|
9
7
|
**Build ChatGPT & MCP Apps. The Modern TypeScript Way.**
|
|
10
8
|
|
|
11
|
-
The fullstack TypeScript framework for AI-embedded
|
|
9
|
+
The fullstack TypeScript framework for AI-embedded views.<br />
|
|
12
10
|
**Type-safe. React-powered. Platform-agnostic.**
|
|
13
11
|
|
|
14
12
|
<br />
|
|
@@ -33,9 +31,9 @@ ChatGPT Apps and MCP Apps let you embed **rich, interactive UIs** directly in AI
|
|
|
33
31
|
|
|
34
32
|
| | |
|
|
35
33
|
|:--|:--|
|
|
36
|
-
|
|
|
37
|
-
| 🔄 **
|
|
38
|
-
|
|
|
34
|
+
| 🌐 **Write once, run everywhere** — Skybridge works seamlessly with ChatGPT (Apps SDK) and MCP-compatible clients. | ✅ **End-to-End Type Safety** — tRPC-style inference from server to view. Autocomplete everywhere. |
|
|
35
|
+
| 🔄 **View-to-Model Sync** — Keep the model aware of UI state with `data-llm`. Dual surfaces, one source of truth. | ⚒️ **React Query-style Hooks** — `isPending`, `isError`, callbacks. State management you already know. |
|
|
36
|
+
| 👨💻 **Full dev environment** — HMR, debug traces, and local devtools. | 📦 **Showcase Examples** — Production-ready examples to learn from and build upon. |
|
|
39
37
|
|
|
40
38
|
<br />
|
|
41
39
|
|
|
@@ -69,7 +67,7 @@ deno add skybridge
|
|
|
69
67
|
|
|
70
68
|
Skybridge is a fullstack framework with unified server and client modules:
|
|
71
69
|
|
|
72
|
-
- **`skybridge/server`** — Define tools and
|
|
70
|
+
- **`skybridge/server`** — Define tools and views with full type inference. Extends the MCP SDK.
|
|
73
71
|
- **`skybridge/web`** — React hooks that consume your server types. Works with Apps SDK (ChatGPT) and MCP Apps.
|
|
74
72
|
- **Dev Environment** — Vite plugin with HMR, DevTools emulator, and optimized builds.
|
|
75
73
|
|
|
@@ -78,7 +76,7 @@ Skybridge is a fullstack framework with unified server and client modules:
|
|
|
78
76
|
```ts
|
|
79
77
|
import { McpServer } from "skybridge/server";
|
|
80
78
|
|
|
81
|
-
server.
|
|
79
|
+
server.registerView("flights", {}, {
|
|
82
80
|
inputSchema: { destination: z.string() },
|
|
83
81
|
}, async ({ destination }) => {
|
|
84
82
|
const flights = await searchFlights(destination);
|
|
@@ -86,12 +84,12 @@ server.registerWidget("flights", {}, {
|
|
|
86
84
|
});
|
|
87
85
|
```
|
|
88
86
|
|
|
89
|
-
###
|
|
87
|
+
### View
|
|
90
88
|
|
|
91
89
|
```tsx
|
|
92
90
|
import { useToolInfo } from "skybridge/web";
|
|
93
91
|
|
|
94
|
-
function
|
|
92
|
+
function FlightsView() {
|
|
95
93
|
const { output } = useToolInfo();
|
|
96
94
|
|
|
97
95
|
return output.structuredContent.flights.map(flight =>
|
|
@@ -106,7 +104,7 @@ function FlightsWidget() {
|
|
|
106
104
|
|
|
107
105
|
- **Live Reload** — Vite HMR. See changes instantly without reinstalling.
|
|
108
106
|
- **Typed Hooks** — Full autocomplete for tools, inputs, outputs.
|
|
109
|
-
- **
|
|
107
|
+
- **View → Tool Calls** — Trigger server actions from UI.
|
|
110
108
|
- **Dual Surface Sync** — Keep model aware of what users see with `data-llm`.
|
|
111
109
|
- **React Query-style API** — `isPending`, `isError`, callbacks.
|
|
112
110
|
- **Platform Agnostic** — Works with ChatGPT (Apps SDK) and MCP Apps clients (Goose, VSCode, etc.).
|
|
@@ -120,11 +118,21 @@ Explore production-ready examples:
|
|
|
120
118
|
|
|
121
119
|
| Example | Description | Demo | Code |
|
|
122
120
|
|------------------------|----------------------------------------------------------------------------------|-----------------------------------------------------|-------------------------------------------------------------------------------------|
|
|
123
|
-
| **
|
|
124
|
-
| **
|
|
125
|
-
| **
|
|
126
|
-
| **
|
|
127
|
-
| **
|
|
121
|
+
| **Awaze — Cottage Search** | Holiday cottage search and booking experience — browse properties, filter by location, and explore availability | [Try Demo](https://mcp.cottages.com/try) | — |
|
|
122
|
+
| **Capitals Explorer** | Interactive world map with geolocation and Wikipedia integration | [Try Demo](https://capitals.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/capitals) |
|
|
123
|
+
| **Ecommerce Carousel** | Product carousel with cart, localization, and modals | [Try Demo](https://ecommerce.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/ecom-carousel) |
|
|
124
|
+
| **Everything** | Comprehensive playground showcasing all hooks and features | [Try Demo](https://everything.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/everything) |
|
|
125
|
+
| **Investigation Game** | Interactive murder mystery game with multi-screen gameplay and dynamic story progression | [Try Demo](https://investigation-game.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/investigation-game) |
|
|
126
|
+
| **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) |
|
|
127
|
+
| **Time's Up** | Word-guessing party game where the user gives hints and the AI tries to guess the secret word | [Try Demo](https://times-up.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/times-up) |
|
|
128
|
+
| **Lumo — Interactive AI Tutor** | Adaptive educational tutor with Mermaid.js 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) |
|
|
129
|
+
| **Auth — Auth0** | Full OAuth authentication with Auth0 and personalized coffee shop search | — | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-auth0) |
|
|
130
|
+
| **Auth — Clerk** | Full OAuth authentication with Clerk and personalized coffee shop search | — | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-clerk) |
|
|
131
|
+
| **Auth — Stytch** | Full OAuth authentication with Stytch and personalized coffee shop search | — | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/auth-stytch) |
|
|
132
|
+
| **Auth — 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) |
|
|
133
|
+
| **Flight Booking** | Flight booking carousel with dynamic search and booking flow | [Try Demo](https://flight-booking.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/flight-booking) |
|
|
134
|
+
| **Generative UI** | Dynamic UI generation using json-render and Skybridge | [Try Demo](https://generative-ui.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/generative-ui) |
|
|
135
|
+
| **Manifest Starter** | Starter app with Manifest UI agentic components out-of-the-box | [Try Demo](https://manifest-ui.skybridge.tech/try) | [View Code](https://github.com/alpic-ai/skybridge/tree/main/examples/manifest-ui) |
|
|
128
136
|
|
|
129
137
|
See all examples in the [Showcase](https://docs.skybridge.tech/showcase) or browse the [examples/](examples/) directory.
|
|
130
138
|
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare function resolvePort(flagPort?: number): Promise<{
|
|
2
|
+
port: number;
|
|
3
|
+
fallback: boolean;
|
|
4
|
+
envWarning?: undefined;
|
|
5
|
+
} | {
|
|
6
|
+
port: number;
|
|
7
|
+
fallback: boolean;
|
|
8
|
+
envWarning: string;
|
|
9
|
+
}>;
|
|
10
|
+
/**
|
|
11
|
+
* Returns the given port if available, otherwise lets the OS
|
|
12
|
+
* pick a free port via `listen(0)`.
|
|
13
|
+
*
|
|
14
|
+
* @param host - Bind address for the check. Pass `"localhost"` for
|
|
15
|
+
* services that bind to 127.0.0.1 (e.g. Vite HMR). Omit for
|
|
16
|
+
* services that bind to all interfaces (e.g. the HTTP server).
|
|
17
|
+
*/
|
|
18
|
+
export declare function detectAvailablePort(startPort: number, host?: string): Promise<number>;
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import net from "node:net";
|
|
2
|
+
const DEFAULT_PORT = 3000;
|
|
3
|
+
export async function resolvePort(flagPort) {
|
|
4
|
+
if (flagPort && flagPort > 1) {
|
|
5
|
+
return { port: flagPort, fallback: false };
|
|
6
|
+
}
|
|
7
|
+
const rawEnv = process.env.PORT;
|
|
8
|
+
if (rawEnv) {
|
|
9
|
+
const parsed = Number(rawEnv);
|
|
10
|
+
if (Number.isInteger(parsed) && parsed > 0) {
|
|
11
|
+
return { port: parsed, fallback: false };
|
|
12
|
+
}
|
|
13
|
+
return {
|
|
14
|
+
port: await detectAvailablePort(DEFAULT_PORT),
|
|
15
|
+
fallback: false,
|
|
16
|
+
envWarning: `Invalid PORT="${rawEnv}", ignoring and using default`,
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
const port = await detectAvailablePort(DEFAULT_PORT);
|
|
20
|
+
return { port, fallback: port !== DEFAULT_PORT };
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Returns the given port if available, otherwise lets the OS
|
|
24
|
+
* pick a free port via `listen(0)`.
|
|
25
|
+
*
|
|
26
|
+
* @param host - Bind address for the check. Pass `"localhost"` for
|
|
27
|
+
* services that bind to 127.0.0.1 (e.g. Vite HMR). Omit for
|
|
28
|
+
* services that bind to all interfaces (e.g. the HTTP server).
|
|
29
|
+
*/
|
|
30
|
+
export async function detectAvailablePort(startPort, host) {
|
|
31
|
+
const available = await isPortAvailable(startPort, host);
|
|
32
|
+
if (available) {
|
|
33
|
+
return startPort;
|
|
34
|
+
}
|
|
35
|
+
return new Promise((resolve, reject) => {
|
|
36
|
+
const server = net.createServer();
|
|
37
|
+
server.once("error", reject);
|
|
38
|
+
server.once("listening", () => {
|
|
39
|
+
const addr = server.address();
|
|
40
|
+
if (addr && typeof addr === "object") {
|
|
41
|
+
const { port } = addr;
|
|
42
|
+
server.close(() => resolve(port));
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
server.close(() => reject(new Error("Failed to detect available port")));
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
server.listen(0, host);
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
function isPortAvailable(port, host) {
|
|
52
|
+
return new Promise((resolve) => {
|
|
53
|
+
const server = net.createServer();
|
|
54
|
+
server.once("error", () => resolve(false));
|
|
55
|
+
server.once("listening", () => {
|
|
56
|
+
server.close(() => resolve(true));
|
|
57
|
+
});
|
|
58
|
+
server.listen(port, host);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=detect-port.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"detect-port.js","sourceRoot":"","sources":["../../src/cli/detect-port.ts"],"names":[],"mappings":"AAAA,OAAO,GAAG,MAAM,UAAU,CAAC;AAE3B,MAAM,YAAY,GAAG,IAAI,CAAC;AAE1B,MAAM,CAAC,KAAK,UAAU,WAAW,CAAC,QAAiB;IACjD,IAAI,QAAQ,IAAI,QAAQ,GAAG,CAAC,EAAE,CAAC;QAC7B,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;IAC7C,CAAC;IAED,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;IAChC,IAAI,MAAM,EAAE,CAAC;QACX,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;QAC9B,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,IAAI,MAAM,GAAG,CAAC,EAAE,CAAC;YAC3C,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC;QAC3C,CAAC;QACD,OAAO;YACL,IAAI,EAAE,MAAM,mBAAmB,CAAC,YAAY,CAAC;YAC7C,QAAQ,EAAE,KAAK;YACf,UAAU,EAAE,iBAAiB,MAAM,+BAA+B;SACnE,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,MAAM,mBAAmB,CAAC,YAAY,CAAC,CAAC;IACrD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,KAAK,YAAY,EAAE,CAAC;AACnD,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,SAAiB,EACjB,IAAa;IAEb,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AC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;QACpC,CAAC,CAAC,CAAC;QAEH,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;AACL,CAAC"}
|
package/dist/cli/header.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { Box, Text } from "ink";
|
|
3
3
|
export const Header = ({ version, children, }) => {
|
|
4
|
-
return (_jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["\u26F0", " ", "
|
|
4
|
+
return (_jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: "cyan", bold: true, children: ["\u26F0", " ", "Skybridge"] }), _jsxs(Text, { color: "cyan", children: [" v", version] }), children] }));
|
|
5
5
|
};
|
|
6
6
|
//# sourceMappingURL=header.js.map
|
package/dist/cli/header.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"header.js","sourceRoot":"","sources":["../../src/cli/header.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,OAAO,EACP,QAAQ,GAIT,EAAE,EAAE;IACH,OAAO,CACL,MAAC,GAAG,IAAC,YAAY,EAAE,CAAC,aAClB,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,EAAC,IAAI,6BACnB,IAAI,
|
|
1
|
+
{"version":3,"file":"header.js","sourceRoot":"","sources":["../../src/cli/header.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,KAAK,CAAC;AAEhC,MAAM,CAAC,MAAM,MAAM,GAAG,CAAC,EACrB,OAAO,EACP,QAAQ,GAIT,EAAE,EAAE;IACH,OAAO,CACL,MAAC,GAAG,IAAC,YAAY,EAAE,CAAC,aAClB,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,EAAC,IAAI,6BACnB,IAAI,iBACD,EACP,MAAC,IAAI,IAAC,KAAK,EAAC,MAAM,mBAAI,OAAO,IAAQ,EACpC,QAAQ,IACL,CACP,CAAC;AACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/cli/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { useCallback, useState } from "react";
|
|
3
|
+
const MAX_MESSAGES = 10;
|
|
4
|
+
export function useMessages() {
|
|
5
|
+
const [messages, setMessages] = useState([]);
|
|
6
|
+
const push = useCallback((text, type) => {
|
|
7
|
+
setMessages((prev) => [...prev, { id: randomUUID(), text, type }].slice(-MAX_MESSAGES));
|
|
8
|
+
}, []);
|
|
9
|
+
return [messages, push];
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=use-messages.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-messages.js","sourceRoot":"","sources":["../../src/cli/use-messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAG9C,MAAM,YAAY,GAAG,EAAE,CAAC;AAIxB,MAAM,UAAU,WAAW;IACzB,MAAM,CAAC,QAAQ,EAAE,WAAW,CAAC,GAAG,QAAQ,CAAiB,EAAE,CAAC,CAAC;IAE7D,MAAM,IAAI,GAAG,WAAW,CAAc,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACnD,WAAW,CAAC,CAAC,IAAI,EAAE,EAAE,CACnB,CAAC,GAAG,IAAI,EAAE,EAAE,EAAE,EAAE,UAAU,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,YAAY,CAAC,CACjE,CAAC;IACJ,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,OAAO,CAAC,QAAQ,EAAE,IAAI,CAAC,CAAC;AAC1B,CAAC"}
|
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
type
|
|
2
|
-
|
|
3
|
-
type: "log" | "restart" | "error";
|
|
4
|
-
};
|
|
5
|
-
export declare function useNodemon(env: NodeJS.ProcessEnv): Array<Message>;
|
|
6
|
-
export {};
|
|
1
|
+
import type { PushMessage } from "./use-messages.js";
|
|
2
|
+
export declare function useNodemon(env: NodeJS.ProcessEnv, pushMessage: PushMessage): void;
|
package/dist/cli/use-nodemon.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { existsSync } from "node:fs";
|
|
2
2
|
import { resolve } from "node:path";
|
|
3
3
|
import nodemonOriginal from "nodemon";
|
|
4
|
-
import { useEffect
|
|
4
|
+
import { useEffect } from "react";
|
|
5
5
|
const nodemon = nodemonOriginal;
|
|
6
|
-
export function useNodemon(env) {
|
|
7
|
-
const [messages, setMessages] = useState([]);
|
|
6
|
+
export function useNodemon(env, pushMessage) {
|
|
8
7
|
useEffect(() => {
|
|
9
8
|
const configFile = resolve(process.cwd(), "nodemon.json");
|
|
10
9
|
const config = existsSync(configFile)
|
|
@@ -12,21 +11,21 @@ export function useNodemon(env) {
|
|
|
12
11
|
configFile,
|
|
13
12
|
}
|
|
14
13
|
: {
|
|
15
|
-
watch: ["
|
|
14
|
+
watch: ["src"],
|
|
16
15
|
ext: "ts,json",
|
|
17
|
-
exec: "tsx
|
|
16
|
+
exec: "tsx src/server.ts",
|
|
18
17
|
};
|
|
19
18
|
nodemon({ ...config, env, stdout: false });
|
|
20
19
|
const handleStdoutData = (chunk) => {
|
|
21
20
|
const message = chunk.toString().trim();
|
|
22
21
|
if (message) {
|
|
23
|
-
|
|
22
|
+
pushMessage(message, "log");
|
|
24
23
|
}
|
|
25
24
|
};
|
|
26
25
|
const handleStderrData = (chunk) => {
|
|
27
26
|
const message = chunk.toString().trim();
|
|
28
27
|
if (message) {
|
|
29
|
-
|
|
28
|
+
pushMessage(message, "error");
|
|
30
29
|
}
|
|
31
30
|
};
|
|
32
31
|
const setupStdoutListener = () => {
|
|
@@ -47,10 +46,7 @@ export function useNodemon(env) {
|
|
|
47
46
|
});
|
|
48
47
|
nodemon.on("restart", (files) => {
|
|
49
48
|
const restartMessage = `Server restarted due to file changes: ${files.join(", ")}`;
|
|
50
|
-
|
|
51
|
-
...prev,
|
|
52
|
-
{ text: restartMessage, type: "restart" },
|
|
53
|
-
]);
|
|
49
|
+
pushMessage(restartMessage, "restart");
|
|
54
50
|
setupStdoutListener();
|
|
55
51
|
setupStderrListener();
|
|
56
52
|
});
|
|
@@ -63,7 +59,6 @@ export function useNodemon(env) {
|
|
|
63
59
|
}
|
|
64
60
|
nodemon.emit("quit");
|
|
65
61
|
};
|
|
66
|
-
}, [env]);
|
|
67
|
-
return messages;
|
|
62
|
+
}, [env, pushMessage]);
|
|
68
63
|
}
|
|
69
64
|
//# sourceMappingURL=use-nodemon.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-nodemon.js","sourceRoot":"","sources":["../../src/cli/use-nodemon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,eAAe,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"use-nodemon.js","sourceRoot":"","sources":["../../src/cli/use-nodemon.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,eAAe,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAIlC,M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+
message: string;
|
|
7
|
+
} | {
|
|
8
|
+
status: "connected";
|
|
9
|
+
url: string;
|
|
10
|
+
} | {
|
|
11
|
+
status: "error";
|
|
12
|
+
message: string;
|
|
13
|
+
};
|
|
14
|
+
export declare function useTunnel(port: number | null, pushMessage: PushMessage, verbose: boolean): TunnelState;
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { useEffect, useState } from "react";
|
|
3
|
+
export function useTunnel(port, pushMessage, verbose) {
|
|
4
|
+
const [state, setState] = useState(port === null
|
|
5
|
+
? { status: "idle" }
|
|
6
|
+
: { status: "starting", message: "Starting tunnel…" });
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (port === null) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const tunnelProcess = spawn("npx", ["--yes", "alpic", "tunnel", "--port", String(port), "--plain"], {
|
|
12
|
+
stdio: ["ignore", "pipe", "pipe"],
|
|
13
|
+
});
|
|
14
|
+
let stderrBuffer = "";
|
|
15
|
+
let connected = false;
|
|
16
|
+
const timeout = setTimeout(() => {
|
|
17
|
+
if (!connected) {
|
|
18
|
+
setState({
|
|
19
|
+
status: "error",
|
|
20
|
+
message: "Tunnel connection timed out after one minute",
|
|
21
|
+
});
|
|
22
|
+
tunnelProcess.kill();
|
|
23
|
+
}
|
|
24
|
+
}, 60_000);
|
|
25
|
+
const pushLog = (text, type) => {
|
|
26
|
+
const time = new Date().toLocaleTimeString("en-US", {
|
|
27
|
+
hour: "numeric",
|
|
28
|
+
minute: "2-digit",
|
|
29
|
+
second: "2-digit",
|
|
30
|
+
hour12: true,
|
|
31
|
+
});
|
|
32
|
+
pushMessage(`${time} [tunnel] ${text}`, type);
|
|
33
|
+
};
|
|
34
|
+
const handleStdout = (data) => {
|
|
35
|
+
const lines = data.toString().trim().split("\n").filter(Boolean);
|
|
36
|
+
for (const line of lines) {
|
|
37
|
+
if (connected) {
|
|
38
|
+
if (verbose) {
|
|
39
|
+
pushLog(line, "log");
|
|
40
|
+
}
|
|
41
|
+
continue;
|
|
42
|
+
}
|
|
43
|
+
const match = line.match(/Forwarding:\s+(https:\/\/\S+)\s*->\s*(\S+)/);
|
|
44
|
+
if (match?.[1]) {
|
|
45
|
+
connected = true;
|
|
46
|
+
clearTimeout(timeout);
|
|
47
|
+
const url = match[1].replace(/\/$/, "");
|
|
48
|
+
setState({ status: "connected", url });
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
setState({ status: "starting", message: line });
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const handleStderr = (data) => {
|
|
56
|
+
const text = data.toString().trim();
|
|
57
|
+
if (!text) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
stderrBuffer = (stderrBuffer + text).slice(-1024);
|
|
61
|
+
if (verbose && connected) {
|
|
62
|
+
for (const line of text.split("\n").filter(Boolean)) {
|
|
63
|
+
pushLog(line, "error");
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
if (tunnelProcess.stdout) {
|
|
68
|
+
tunnelProcess.stdout.on("data", handleStdout);
|
|
69
|
+
}
|
|
70
|
+
if (tunnelProcess.stderr) {
|
|
71
|
+
tunnelProcess.stderr.on("data", handleStderr);
|
|
72
|
+
}
|
|
73
|
+
tunnelProcess.on("error", (err) => {
|
|
74
|
+
clearTimeout(timeout);
|
|
75
|
+
setState({ status: "error", message: err.message });
|
|
76
|
+
});
|
|
77
|
+
tunnelProcess.on("close", (code) => {
|
|
78
|
+
clearTimeout(timeout);
|
|
79
|
+
if (code !== 0 && code !== null) {
|
|
80
|
+
const detail = stderrBuffer.trim() || `exited with code ${code}`;
|
|
81
|
+
const hint = verbose
|
|
82
|
+
? `Try manually: npx alpic tunnel --port ${port}`
|
|
83
|
+
: "Re-run with --verbose to see full tunnel logs";
|
|
84
|
+
setState({
|
|
85
|
+
status: "error",
|
|
86
|
+
message: `${detail}. ${hint}`,
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
return () => {
|
|
91
|
+
clearTimeout(timeout);
|
|
92
|
+
tunnelProcess.kill();
|
|
93
|
+
};
|
|
94
|
+
}, [port, pushMessage, verbose]);
|
|
95
|
+
return state;
|
|
96
|
+
}
|
|
97
|
+
//# sourceMappingURL=use-tunnel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-tunnel.js","sourceRoot":"","sources":["../../src/cli/use-tunnel.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,oBAAoB,CAAC;AAC3C,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAS5C,MAAM,UAAU,SAAS,CACvB,IAAmB,EACnB,WAAwB,EACxB,OAAgB;IAEhB,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAChC,IAAI,KAAK,IAAI;QACX,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE;QACpB,CAAC,CAAC,EAAE,MAAM,EAAE,UAAU,EAAE,OAAO,EAAE,kBAAkB,EAAE,CACxD,CAAC;IAEF,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;YAClB,OAAO;QACT,CAAC;QAED,MAAM,aAAa,GAAG,KAAK,CACzB,KAAK,EACL,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,CAAC,IAAI,CAAC,EAAE,SAAS,CAAC,EAC/D;YACE,KAAK,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,CAAC;SAClC,CACF,CAAC;QAEF,IAAI,YAAY,GAAG,EAAE,CAAC;QACtB,IAAI,SAAS,GAAG,KAAK,CAAC;QAEtB,MAAM,OAAO,GAAG,UAAU,CAAC,GAAG,EAAE;YAC9B,IAAI,CAAC,SAAS,EAAE,CAAC;gBACf,QAAQ,CAAC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,CAAC,CAAC;YACtB,IAAI,IAAI,KAAK,CAAC,IAAI,IAAI,KAAK,IAAI,EAAE,CAAC;gBAChC,MAAM,MAAM,GAAG,YAAY,CAAC,IAAI,EAAE,IAAI,oBAAoB,IAAI,EAAE,CAAC;gBACjE,MAAM,IAAI,GAAG,OAAO;oBAClB,CAAC,CAAC,yCAAyC,IAAI,EAAE;oBACjD,CAAC,CAAC,+CAA+C,CAAC;gBACpD,QAAQ,CAAC;oBACP,MAAM,EAAE,OAAO;oBACf,OAAO,EAAE,GAAG,MAAM,KAAK,IAAI,EAAE;iBAC9B,CAAC,CAAC;YACL,CAAC;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,aAAa,CAAC,IAAI,EAAE,CAAC;QACvB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,CAAC,CAAC,CAAC;IAEjC,OAAO,KAAK,CAAC;AACf,CAAC"}
|
package/dist/commands/build.js
CHANGED
|
@@ -1,27 +1,48 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import {
|
|
2
|
+
import { rmSync } from "node:fs";
|
|
3
3
|
import { Command } from "@oclif/core";
|
|
4
4
|
import { Box, render, Text } from "ink";
|
|
5
5
|
import { useEffect } from "react";
|
|
6
6
|
import { Header } from "../cli/header.js";
|
|
7
7
|
import { useExecuteSteps } from "../cli/use-execute-steps.js";
|
|
8
|
+
import { scanAndWriteViewsDts } from "../web/plugin/scan-views.js";
|
|
9
|
+
async function resolveViewsDir(root) {
|
|
10
|
+
const { loadConfigFromFile } = await import("vite");
|
|
11
|
+
const loaded = await loadConfigFromFile({ command: "build", mode: "production" }, undefined, root);
|
|
12
|
+
const isPluginCandidate = (value) => typeof value === "object" && value !== null;
|
|
13
|
+
const plugins = [];
|
|
14
|
+
const walk = (value) => {
|
|
15
|
+
if (Array.isArray(value)) {
|
|
16
|
+
value.forEach(walk);
|
|
17
|
+
}
|
|
18
|
+
else if (isPluginCandidate(value)) {
|
|
19
|
+
plugins.push(value);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
walk(loaded?.config.plugins ?? []);
|
|
23
|
+
return plugins.find((p) => p.name === "skybridge")?.api?.viewsDir;
|
|
24
|
+
}
|
|
8
25
|
export const commandSteps = [
|
|
9
26
|
{
|
|
10
|
-
label: "
|
|
11
|
-
|
|
27
|
+
label: "Scanning views",
|
|
28
|
+
run: async () => {
|
|
29
|
+
const root = process.cwd();
|
|
30
|
+
const viewsDir = await resolveViewsDir(root);
|
|
31
|
+
scanAndWriteViewsDts(root, viewsDir);
|
|
32
|
+
},
|
|
12
33
|
},
|
|
13
34
|
{
|
|
14
35
|
label: "Compiling server",
|
|
15
36
|
run: () => rmSync("dist", { recursive: true, force: true }),
|
|
16
|
-
command: "tsc -
|
|
37
|
+
command: "tsc -b --force",
|
|
17
38
|
},
|
|
18
39
|
{
|
|
19
|
-
label: "
|
|
20
|
-
|
|
40
|
+
label: "Building views",
|
|
41
|
+
command: "vite build",
|
|
21
42
|
},
|
|
22
43
|
];
|
|
23
44
|
export default class Build extends Command {
|
|
24
|
-
static description = "Build the
|
|
45
|
+
static description = "Build the views and MCP server";
|
|
25
46
|
static examples = ["skybridge build"];
|
|
26
47
|
static flags = {};
|
|
27
48
|
async run() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"build.js","sourceRoot":"","sources":["../../src/commands/build.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,EA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AM,CAAC,KAAC,GAAG,KAAG,EAAE;YACd,WAAW,EAAE,IAAI;YACjB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC"}
|
package/dist/commands/dev.d.ts
CHANGED
|
@@ -3,7 +3,9 @@ export default class Dev extends Command {
|
|
|
3
3
|
static description: string;
|
|
4
4
|
static examples: string[];
|
|
5
5
|
static flags: {
|
|
6
|
-
"
|
|
6
|
+
port: import("@oclif/core/interfaces").OptionFlag<number | undefined, import("@oclif/core/interfaces").CustomOptions>;
|
|
7
|
+
tunnel: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
8
|
+
verbose: import("@oclif/core/interfaces").BooleanFlag<boolean>;
|
|
7
9
|
};
|
|
8
10
|
run(): Promise<void>;
|
|
9
11
|
}
|
package/dist/commands/dev.js
CHANGED
|
@@ -1,29 +1,47 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { Command, Flags } from "@oclif/core";
|
|
3
3
|
import { Box, render, Text } from "ink";
|
|
4
|
+
import { resolvePort } from "../cli/detect-port.js";
|
|
4
5
|
import { Header } from "../cli/header.js";
|
|
6
|
+
import { useMessages } from "../cli/use-messages.js";
|
|
5
7
|
import { useNodemon } from "../cli/use-nodemon.js";
|
|
8
|
+
import { useTunnel } from "../cli/use-tunnel.js";
|
|
6
9
|
import { useTypeScriptCheck } from "../cli/use-typescript-check.js";
|
|
7
10
|
export default class Dev extends Command {
|
|
8
11
|
static description = "Start development server";
|
|
9
12
|
static examples = ["skybridge"];
|
|
10
13
|
static flags = {
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
port: Flags.integer({
|
|
15
|
+
char: "p",
|
|
16
|
+
description: "Port to run the server on",
|
|
17
|
+
min: 1,
|
|
18
|
+
}),
|
|
19
|
+
tunnel: Flags.boolean({
|
|
20
|
+
description: "Open an Alpic tunnel for remote testing",
|
|
21
|
+
default: false,
|
|
22
|
+
}),
|
|
23
|
+
verbose: Flags.boolean({
|
|
24
|
+
char: "v",
|
|
25
|
+
description: "Show tunnel logs",
|
|
26
|
+
default: false,
|
|
13
27
|
}),
|
|
14
28
|
};
|
|
15
29
|
async run() {
|
|
16
30
|
const { flags } = await this.parse(Dev);
|
|
31
|
+
const { port, fallback, envWarning } = await resolvePort(flags.port);
|
|
32
|
+
if (envWarning) {
|
|
33
|
+
this.warn(envWarning);
|
|
34
|
+
}
|
|
17
35
|
const env = {
|
|
18
36
|
...process.env,
|
|
19
|
-
|
|
20
|
-
? { SKYBRIDGE_USE_FORWARDED_HOST: "true" }
|
|
21
|
-
: {}),
|
|
37
|
+
__PORT: String(port),
|
|
22
38
|
};
|
|
23
39
|
const App = () => {
|
|
24
40
|
const tsErrors = useTypeScriptCheck();
|
|
25
|
-
const messages =
|
|
26
|
-
|
|
41
|
+
const [messages, pushMessage] = useMessages();
|
|
42
|
+
useNodemon(env, pushMessage);
|
|
43
|
+
const tunnelState = useTunnel(flags.tunnel ? port : null, pushMessage, flags.verbose);
|
|
44
|
+
return (_jsxs(Box, { flexDirection: "column", padding: 1, marginLeft: 1, children: [_jsx(Header, { version: this.config.version }), _jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDFE0", " "] }), fallback ? (_jsx(Text, { color: "yellow", children: "3000 in use, running on " })) : (_jsx(Text, { children: "Running on " })), _jsx(Text, { color: "green", children: `http://localhost:${port}/mcp` })] }), _jsxs(Box, { marginBottom: 1, children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsxs(Text, { color: "white", bold: true, children: ["Test locally with DevTools:", " "] }), _jsx(Text, { color: "green", children: `http://localhost:${port}/` })] }), tunnelState.status === "idle" && (_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { children: "Get a public URL and LLM Playground access with " }), _jsx(Text, { color: "cyan", bold: true, children: "--tunnel" }), _jsx(Text, { children: "." })] })), tunnelState.status === "starting" && (_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { color: "yellow", children: tunnelState.message })] })), tunnelState.status === "connected" && (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsx(Text, { children: "Exposed on " }), _jsx(Text, { color: "green", children: `${tunnelState.url}/mcp` })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsxs(Text, { color: "white", bold: true, children: ["Test with an LLM on Playground:", " "] }), _jsx(Text, { color: "green", children: `${tunnelState.url}/try` })] })] })), tunnelState.status === "error" && (_jsxs(Box, { flexDirection: "column", marginBottom: 1, children: [_jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83C\uDF0D", " "] }), _jsxs(Text, { color: "red", children: ["Cannot open tunnel: ", tunnelState.message] })] }), _jsxs(Box, { children: [_jsxs(Text, { color: "#20a832", children: ["\u2192", " "] }), _jsx(Text, { color: "red", children: `Try manually: npx alpic tunnel --port ${port}` })] })] })), _jsxs(Box, { children: [_jsxs(Text, { children: ["\uD83D\uDEDF", " "] }), _jsx(Text, { children: "Need help? Reach us on " }), _jsx(Text, { color: "white", underline: true, children: "https://discord.alpic.ai" })] }), tsErrors.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "red", bold: true, children: "\u26A0\uFE0F TypeScript errors found:" }), tsErrors.map((error) => (_jsxs(Box, { marginLeft: 2, flexDirection: "column", children: [_jsxs(Box, { children: [_jsx(Text, { color: "white", children: error.file }), _jsxs(Text, { color: "grey", children: ["(", error.line, ",", error.col, "):", " "] })] }), _jsx(Box, { marginLeft: 2, children: _jsx(Text, { color: "red", children: error.message }) })] }, `${error.file}:${error.line}:${error.col}`)))] })), messages.length > 0 && (_jsxs(Box, { marginTop: 1, flexDirection: "column", children: [_jsx(Text, { color: "white", bold: true, children: "Logs:" }), messages.map((message) => (_jsx(Box, { marginLeft: 2, children: message.type === "restart" ? (_jsxs(_Fragment, { children: [_jsxs(Text, { color: "green", children: ["\u2713", " "] }), _jsx(Text, { color: "white", children: message.text })] })) : message.type === "error" ? (_jsx(Text, { color: "red", children: message.text })) : (_jsx(Text, { children: message.text })) }, message.id)))] }))] }));
|
|
27
45
|
};
|
|
28
46
|
render(_jsx(App, {}), { exitOnCtrlC: true, patchConsole: true });
|
|
29
47
|
}
|