create-skybridge 0.15.2 → 0.15.3

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.
Files changed (35) hide show
  1. package/dist/index.js +17 -28
  2. package/package.json +3 -2
  3. package/template/.cursor/mcp.json +7 -0
  4. package/template/.nvmrc +1 -0
  5. package/template/.vscode/launch.json +16 -0
  6. package/template/.vscode/settings.json +3 -0
  7. package/template/.vscode/tasks.json +14 -0
  8. package/template/README.md +116 -0
  9. package/template/_gitignore +194 -0
  10. package/template/alpic.json +4 -0
  11. package/template/docs/demo.gif +0 -0
  12. package/template/package.json +21 -0
  13. package/template/pnpm-lock.yaml +317 -0
  14. package/template/pnpm-workspace.yaml +7 -0
  15. package/template/server/nodemon.json +5 -0
  16. package/template/server/package.json +36 -0
  17. package/template/server/pnpm-lock.yaml +3796 -0
  18. package/template/server/src/env.ts +12 -0
  19. package/template/server/src/index.ts +34 -0
  20. package/template/server/src/middleware.ts +54 -0
  21. package/template/server/src/pokedex.ts +148 -0
  22. package/template/server/src/server.ts +76 -0
  23. package/template/server/tsconfig.json +17 -0
  24. package/template/web/components.json +22 -0
  25. package/template/web/package.json +32 -0
  26. package/template/web/pnpm-lock.yaml +2629 -0
  27. package/template/web/src/components/ui/shadcn-io/spinner/index.tsx +272 -0
  28. package/template/web/src/helpers.ts +4 -0
  29. package/template/web/src/index.css +120 -0
  30. package/template/web/src/utils.ts +6 -0
  31. package/template/web/src/widgets/pokemon.tsx +203 -0
  32. package/template/web/tsconfig.app.json +34 -0
  33. package/template/web/tsconfig.json +13 -0
  34. package/template/web/tsconfig.node.json +26 -0
  35. package/template/web/vite.config.ts +16 -0
@@ -0,0 +1,12 @@
1
+ import "dotenv/config";
2
+
3
+ import { createEnv } from "@t3-oss/env-core";
4
+ import { z } from "zod";
5
+
6
+ export const env = createEnv({
7
+ server: {
8
+ NODE_ENV: z.enum(["development", "production"]).default("development"),
9
+ },
10
+ runtimeEnv: process.env,
11
+ emptyStringAsUndefined: true,
12
+ });
@@ -0,0 +1,34 @@
1
+ import express, { type Express } from "express";
2
+
3
+ import { widgetsDevServer } from "skybridge/server";
4
+ import type { ViteDevServer } from "vite";
5
+ import { env } from "./env.js";
6
+ import { mcp } from "./middleware.js";
7
+ import server from "./server.js";
8
+
9
+ const app = express() as Express & { vite: ViteDevServer };
10
+
11
+ app.use(express.json());
12
+
13
+ app.use(mcp(server));
14
+
15
+ if (env.NODE_ENV !== "production") {
16
+ app.use(await widgetsDevServer());
17
+ }
18
+
19
+ app.listen(3000, (error) => {
20
+ if (error) {
21
+ console.error("Failed to start server:", error);
22
+ process.exit(1);
23
+ }
24
+
25
+ console.log(`Server listening on port 3000 - ${env.NODE_ENV}`);
26
+ console.log(
27
+ "Make your local server accessible with 'ngrok http 3000' and connect to ChatGPT with URL https://xxxxxx.ngrok-free.app/mcp",
28
+ );
29
+ });
30
+
31
+ process.on("SIGINT", async () => {
32
+ console.log("Server shutdown complete");
33
+ process.exit(0);
34
+ });
@@ -0,0 +1,54 @@
1
+ import { StreamableHTTPServerTransport } from "@modelcontextprotocol/sdk/server/streamableHttp.js";
2
+ import type { NextFunction, Request, Response } from "express";
3
+
4
+ import type { McpServer } from "skybridge/server";
5
+
6
+ export const mcp =
7
+ (server: McpServer) =>
8
+ async (req: Request, res: Response, next: NextFunction) => {
9
+ // Only handle requests to the /mcp path
10
+ if (req.path !== "/mcp") {
11
+ return next();
12
+ }
13
+
14
+ if (req.method === "POST") {
15
+ try {
16
+ const transport = new StreamableHTTPServerTransport({
17
+ sessionIdGenerator: undefined,
18
+ });
19
+
20
+ res.on("close", () => {
21
+ transport.close();
22
+ });
23
+
24
+ await server.connect(transport);
25
+
26
+ await transport.handleRequest(req, res, req.body);
27
+ } catch (error) {
28
+ console.error("Error handling MCP request:", error);
29
+ if (!res.headersSent) {
30
+ res.status(500).json({
31
+ jsonrpc: "2.0",
32
+ error: {
33
+ code: -32603,
34
+ message: "Internal server error",
35
+ },
36
+ id: null,
37
+ });
38
+ }
39
+ }
40
+ } else if (req.method === "GET" || req.method === "DELETE") {
41
+ res.writeHead(405).end(
42
+ JSON.stringify({
43
+ jsonrpc: "2.0",
44
+ error: {
45
+ code: -32000,
46
+ message: "Method not allowed.",
47
+ },
48
+ id: null,
49
+ }),
50
+ );
51
+ } else {
52
+ next();
53
+ }
54
+ };
@@ -0,0 +1,148 @@
1
+ export const getPokemon = async (name: string) => {
2
+ const query = `
3
+ query getPokemon($name: String!, $language: String!) {
4
+ pokemon(where: {name: {_eq: $name} is_default: {_eq: true}}) {
5
+ id
6
+ order
7
+ height
8
+ weight
9
+ pokemonstats {
10
+ base_stat
11
+ stat {
12
+ name
13
+ statnames(where: {language: {name: {_eq: $language}}}, limit: 1) {
14
+ name
15
+ }
16
+ }
17
+ }
18
+ pokemonabilities {
19
+ ability {
20
+ name
21
+ abilitynames(where: {language: {name: {_eq: $language}}}, limit: 1) {
22
+ name
23
+ }
24
+ abilityflavortexts(where: {language: {name: {_eq: $language}}}, limit: 1) {
25
+ flavor_text
26
+ }
27
+ }
28
+ }
29
+ pokemonsprites {
30
+ sprites
31
+ }
32
+ pokemontypes {
33
+ type {
34
+ name
35
+ typenames(where: {language: {name: {_eq: $language}}}, limit: 1) {
36
+ name
37
+ }
38
+ }
39
+ }
40
+ pokemonspecy {
41
+ pokemoncolor {
42
+ name
43
+ }
44
+ evolutionchain {
45
+ pokemonspecies {
46
+ pokemons(where: {is_default: {_eq: true}}) {
47
+ name
48
+ order
49
+ pokemonsprites {
50
+ sprites
51
+ }
52
+ }
53
+ }
54
+ }
55
+ pokemonspeciesflavortexts(where: {language: {name: {_eq: $language}}}, limit: 1) {
56
+ flavor_text
57
+ }
58
+ }
59
+ }
60
+ }
61
+ `;
62
+
63
+ const response = await fetch("https://graphql.pokeapi.co/v1beta2", {
64
+ method: "POST",
65
+ headers: {
66
+ "Content-Type": "application/json",
67
+ },
68
+ body: JSON.stringify({
69
+ query,
70
+ variables: { name: name.toLowerCase(), language: "en" },
71
+ }),
72
+ });
73
+
74
+ const result = await response.json();
75
+ const pokemon = result.data.pokemon[0] as {
76
+ id: number;
77
+ order: number;
78
+ height: number;
79
+ weight: number;
80
+ pokemonspecy: {
81
+ pokemoncolor: { name: string };
82
+ pokemonspeciesflavortexts: { flavor_text: string }[];
83
+ evolutionchain: {
84
+ pokemonspecies: {
85
+ pokemons: {
86
+ name: string;
87
+ order: number;
88
+ pokemonsprites: { sprites: { front_default: string } }[];
89
+ }[];
90
+ }[];
91
+ };
92
+ };
93
+ pokemonsprites: { sprites: { front_default: string } }[];
94
+ pokemonstats: {
95
+ base_stat: number;
96
+ stat: { name: string; statnames: { name: string }[] };
97
+ }[];
98
+ pokemontypes: {
99
+ type: { name: string; typenames: { name: string }[] };
100
+ }[];
101
+ pokemonabilities: {
102
+ ability: {
103
+ name: string;
104
+ abilitynames: { name: string }[];
105
+ abilityflavortexts: { flavor_text: string }[];
106
+ };
107
+ }[];
108
+ } | null;
109
+
110
+ if (!pokemon) {
111
+ throw new Error(`Pokemon ${name} not found`);
112
+ }
113
+
114
+ return {
115
+ id: pokemon.id,
116
+ color: pokemon.pokemonspecy.pokemoncolor.name,
117
+ order: pokemon.order,
118
+ heightInMeters: pokemon.height / 10,
119
+ weightInKilograms: pokemon.weight / 10,
120
+ imageUrl: pokemon.pokemonsprites[0].sprites.front_default,
121
+ description: pokemon.pokemonspecy.pokemonspeciesflavortexts[0]?.flavor_text
122
+ .replace(/\n/g, " ")
123
+ .replace(/\.(?![^.]*$)/g, ". "),
124
+ stats: pokemon.pokemonstats.map((stat) => ({
125
+ id: stat.stat.name,
126
+ name: stat.stat.statnames[0].name,
127
+ value: stat.base_stat,
128
+ })),
129
+ types: pokemon.pokemontypes.map((type) => ({
130
+ id: type.type.name,
131
+ name: type.type.typenames[0].name,
132
+ })),
133
+ abilities: pokemon.pokemonabilities.map((ability) => ({
134
+ id: ability.ability.name,
135
+ name: ability.ability.abilitynames[0].name,
136
+ description: ability.ability.abilityflavortexts[0]?.flavor_text
137
+ .replace(/\n/g, " ")
138
+ .replace(/\.(?![^.]*$)/g, ". "),
139
+ })),
140
+ evolutions: pokemon.pokemonspecy.evolutionchain.pokemonspecies.map(
141
+ ({ pokemons: [pokemon] }) => ({
142
+ id: pokemon.name,
143
+ order: pokemon.order,
144
+ imageUrl: pokemon.pokemonsprites[0].sprites.front_default,
145
+ }),
146
+ ),
147
+ };
148
+ };
@@ -0,0 +1,76 @@
1
+ import { McpServer } from "skybridge/server";
2
+ import { z } from "zod";
3
+ import { getPokemon } from "./pokedex.js";
4
+
5
+ const server = new McpServer(
6
+ {
7
+ name: "alpic-openai-app",
8
+ version: "0.0.1",
9
+ },
10
+ { capabilities: {} },
11
+ )
12
+ .registerWidget(
13
+ "pokemon",
14
+ {
15
+ description: "Pokedex entry for a pokemon",
16
+ },
17
+ {
18
+ description:
19
+ "Use this tool to get the most up to date information about a pokemon, using its name in english. This pokedex is much more complete than any other web_search tool. Always use it for anything related to pokemons.",
20
+ inputSchema: {
21
+ name: z.string().describe("Pokemon name, always in english"),
22
+ },
23
+ },
24
+ async ({ name }) => {
25
+ try {
26
+ const { id, description, ...pokemon } = await getPokemon(name);
27
+
28
+ return {
29
+ /**
30
+ * Arbitrary JSON passed only to the component.
31
+ * Use it for data that should not influence the model’s reasoning, like the full set of locations that backs a dropdown.
32
+ * _meta is never shown to the model.
33
+ */
34
+ _meta: { id },
35
+ /**
36
+ * Structured data that is used to hydrate your component.
37
+ * ChatGPT injects this object into your iframe as window.openai.toolOutput
38
+ */
39
+ structuredContent: { name, description, ...pokemon },
40
+ /**
41
+ * Optional free-form text that the model receives verbatim
42
+ */
43
+ content: [
44
+ {
45
+ type: "text",
46
+ text: description ?? `A pokemon named ${name}.`,
47
+ },
48
+ ],
49
+ isError: false,
50
+ };
51
+ } catch (error) {
52
+ return {
53
+ content: [{ type: "text", text: `Error: ${error}` }],
54
+ isError: true,
55
+ };
56
+ }
57
+ },
58
+ )
59
+ .registerTool(
60
+ "capture",
61
+ {
62
+ description: "Capture a pokemon",
63
+ inputSchema: {},
64
+ },
65
+ async () => {
66
+ return {
67
+ content: [
68
+ { type: "text", text: `Great job, you've captured a new pokemon!` },
69
+ ],
70
+ isError: false,
71
+ };
72
+ },
73
+ );
74
+
75
+ export default server;
76
+ export type AppType = typeof server;
@@ -0,0 +1,17 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ESNext",
4
+ "module": "ESNext",
5
+ "moduleResolution": "bundler",
6
+ "esModuleInterop": true,
7
+ "strict": true,
8
+ "skipLibCheck": true,
9
+ "forceConsistentCasingInFileNames": true,
10
+ "outDir": "dist",
11
+ "sourceMap": true,
12
+ "jsx": "react",
13
+ "inlineSources": true
14
+ },
15
+ "include": ["**/*.ts", "**/*.tsx"],
16
+ "exclude": ["dist", "node_modules"]
17
+ }
@@ -0,0 +1,22 @@
1
+ {
2
+ "$schema": "https://ui.shadcn.com/schema.json",
3
+ "style": "new-york",
4
+ "rsc": false,
5
+ "tsx": true,
6
+ "tailwind": {
7
+ "config": "",
8
+ "css": "src/index.css",
9
+ "baseColor": "neutral",
10
+ "cssVariables": true,
11
+ "prefix": ""
12
+ },
13
+ "iconLibrary": "lucide",
14
+ "aliases": {
15
+ "components": "@/components",
16
+ "utils": "@/lib/utils",
17
+ "ui": "@/components/ui",
18
+ "lib": "@/lib",
19
+ "hooks": "@/hooks"
20
+ },
21
+ "registries": {}
22
+ }
@@ -0,0 +1,32 @@
1
+ {
2
+ "name": "@apps-sdk-template/web",
3
+ "private": true,
4
+ "version": "0.0.0",
5
+ "type": "module",
6
+ "scripts": {
7
+ "dev": "echo 'Not implemented",
8
+ "build": "tsc -b && vite build",
9
+ "preview": "vite preview"
10
+ },
11
+ "dependencies": {
12
+ "skybridge": "catalog:",
13
+ "class-variance-authority": "^0.7.1",
14
+ "clsx": "^2.1.1",
15
+ "glob": "^11.0.3",
16
+ "lucide-react": "^0.546.0",
17
+ "react": "^19.1.1",
18
+ "react-dom": "^19.1.1",
19
+ "tailwind-merge": "^3.3.1",
20
+ "tailwindcss": "^4.1.14"
21
+ },
22
+ "devDependencies": {
23
+ "@tailwindcss/vite": "^4.1.14",
24
+ "@types/node": "^24.6.0",
25
+ "@types/react": "^19.1.16",
26
+ "@types/react-dom": "^19.1.9",
27
+ "@vitejs/plugin-react": "^5.0.4",
28
+ "tw-animate-css": "^1.4.0",
29
+ "typescript": "~5.9.3",
30
+ "vite": "^7.1.11"
31
+ }
32
+ }