create-skybridge 0.0.0-dev.e159727 → 0.0.0-dev.e17f86d

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 (34) hide show
  1. package/dist/index.test.js +2 -0
  2. package/package.json +1 -1
  3. package/template/.dockerignore +4 -0
  4. package/template/Dockerfile +53 -0
  5. package/template/package.json +7 -1
  6. package/template/src/index.css +37 -130
  7. package/template/src/server.ts +59 -43
  8. package/template/src/views/components/doc-link.tsx +22 -0
  9. package/template/src/views/components/doc.tsx +21 -0
  10. package/template/src/views/components/nav.tsx +31 -0
  11. package/template/src/views/components/progress.tsx +35 -0
  12. package/template/src/views/components/steps/outro.tsx +68 -0
  13. package/template/src/views/components/steps/state.tsx +47 -0
  14. package/template/src/views/components/steps/tool-call.tsx +53 -0
  15. package/template/src/views/components/steps/tool-output.tsx +40 -0
  16. package/template/src/views/images/mascot/beret.png +0 -0
  17. package/template/src/views/images/mascot/chapka.png +0 -0
  18. package/template/src/views/images/mascot/cowboy-hat.png +0 -0
  19. package/template/src/views/images/mascot/fez.png +0 -0
  20. package/template/src/views/images/mascot/jester-hat.png +0 -0
  21. package/template/src/views/images/mascot/mitre.png +0 -0
  22. package/template/src/views/images/mascot/non-la.png +0 -0
  23. package/template/src/views/images/mascot/original.png +0 -0
  24. package/template/src/views/images/mascot/propeller-beanie.png +0 -0
  25. package/template/src/views/images/mascot/ski-mask.png +0 -0
  26. package/template/src/views/images/mascot/sombrero.png +0 -0
  27. package/template/src/views/images/mascot/top-hat.png +0 -0
  28. package/template/src/views/images/mascot/viking-helmet.png +0 -0
  29. package/template/src/views/onboarding.tsx +63 -0
  30. package/template/src/views/use-mascot.ts +60 -0
  31. package/template/src/vite-manifest.d.ts +4 -0
  32. package/template/vite.config.ts +2 -1
  33. package/template/src/components/ball.tsx +0 -22
  34. package/template/src/views/magic-8-ball.tsx +0 -10
@@ -18,6 +18,8 @@ describe("create-skybridge", () => {
18
18
  const name = `../../${tempDirName}//project$`;
19
19
  await init([name]);
20
20
  await fs.access(path.join(process.cwd(), tempDirName, "project", ".gitignore"));
21
+ await fs.access(path.join(process.cwd(), tempDirName, "project", ".dockerignore"));
22
+ await fs.access(path.join(process.cwd(), tempDirName, "project", "Dockerfile"));
21
23
  expect(fs.access(path.join(process.cwd(), tempDirName, "project", ".npmrc"))).rejects.toThrowError();
22
24
  });
23
25
  it("should download template from repo", { timeout: 10000 }, async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-skybridge",
3
- "version": "0.0.0-dev.e159727",
3
+ "version": "0.0.0-dev.e17f86d",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "Alpic",
@@ -0,0 +1,4 @@
1
+ node_modules
2
+ .git
3
+ dist
4
+ .env*
@@ -0,0 +1,53 @@
1
+ # syntax=docker/dockerfile:1
2
+
3
+ # Dockerfile for a Skybridge MCP server.
4
+ #
5
+ # Detects npm, yarn, or pnpm from the lockfile in your project.
6
+ # (For bun or deno, adapt the install/build/prune commands below.)
7
+
8
+ # Build stage: install deps, compile the app, then prune dev deps.
9
+ FROM node:24-slim AS build
10
+ WORKDIR /app
11
+
12
+ COPY package.json yarn.lock* package-lock.json* pnpm-lock.yaml* .npmrc* ./
13
+ RUN --mount=type=cache,target=/root/.npm \
14
+ --mount=type=cache,target=/usr/local/share/.cache/yarn \
15
+ --mount=type=cache,target=/root/.local/share/pnpm/store \
16
+ if [ -f package-lock.json ]; then \
17
+ npm ci; \
18
+ elif [ -f yarn.lock ]; then \
19
+ corepack enable yarn && yarn install --frozen-lockfile; \
20
+ elif [ -f pnpm-lock.yaml ]; then \
21
+ corepack enable pnpm && pnpm install --frozen-lockfile; \
22
+ else \
23
+ echo "No lockfile found." && exit 1; \
24
+ fi
25
+
26
+ ENV NODE_ENV=production
27
+
28
+ COPY . .
29
+ RUN if [ -f package-lock.json ]; then \
30
+ npm run build && npm prune --omit=dev; \
31
+ elif [ -f yarn.lock ]; then \
32
+ corepack enable yarn && yarn build && yarn install --frozen-lockfile --production=true; \
33
+ elif [ -f pnpm-lock.yaml ]; then \
34
+ corepack enable pnpm && pnpm build && pnpm prune --prod; \
35
+ fi
36
+
37
+ # Runtime stage: copy built artifacts and prod deps, run as non-root.
38
+ FROM node:24-slim AS runtime
39
+ WORKDIR /app
40
+ ENV NODE_ENV=production
41
+
42
+ USER node
43
+
44
+ COPY --from=build --chown=node:node /app/node_modules ./node_modules
45
+ COPY --from=build --chown=node:node /app/dist ./dist
46
+ COPY --from=build --chown=node:node /app/package.json ./package.json
47
+
48
+ EXPOSE 3000
49
+
50
+ # Run the built server directly rather than via `npm start` / `skybridge start`.
51
+ # Each wrapper adds a process layer that can swallow SIGTERM, which makes
52
+ # graceful shutdowns time out on platforms like Cloud Run, Fly, and k8s.
53
+ CMD ["node", "dist/server.js"]
@@ -12,20 +12,26 @@
12
12
  "deploy": "alpic deploy"
13
13
  },
14
14
  "dependencies": {
15
+ "@alpic-ai/ui": "^1.122.0",
15
16
  "@modelcontextprotocol/sdk": "^1.29.0",
17
+ "lucide-react": "^1.14.0",
16
18
  "react": "^19.2.4",
17
19
  "react-dom": "^19.2.4",
18
- "skybridge": ">=0.0.0-dev.e159727",
20
+ "skybridge": ">=0.0.0-dev.e17f86d",
21
+ "sonner": "^2.0.7",
22
+ "tw-animate-css": "^1.4.0",
19
23
  "vite": "^8.0.3",
20
24
  "zod": "^4.3.6"
21
25
  },
22
26
  "devDependencies": {
23
27
  "@skybridge/devtools": ">=0.35.14 <1.0.0",
28
+ "@tailwindcss/vite": "^4.2.4",
24
29
  "@types/node": "^24.12.0",
25
30
  "@types/react": "^19.2.14",
26
31
  "@types/react-dom": "^19.2.3",
27
32
  "@vitejs/plugin-react": "^6.0.1",
28
33
  "alpic": "^1.104.1",
34
+ "tailwindcss": "^4.2.4",
29
35
  "tsx": "^4.21.0",
30
36
  "typescript": "^6.0.2"
31
37
  },
@@ -1,50 +1,35 @@
1
- @import url("https://fonts.googleapis.com/css2?family=Playfair+Display:ital,wght@1,600&display=swap");
1
+ @import url("https://fonts.googleapis.com/css2?family=Mozilla+Text:wght@400..700&display=swap");
2
+ @import "tailwindcss";
3
+ @import "tw-animate-css";
4
+ @import "@alpic-ai/ui/theme";
2
5
 
3
- .container {
4
- display: flex;
5
- justify-content: center;
6
- align-items: center;
7
- min-height: 100%;
8
- padding: 1rem;
9
- box-sizing: border-box;
6
+ @source "../node_modules/@alpic-ai/ui/src";
7
+
8
+ @theme {
9
+ --font-mozilla: "Mozilla Text", serif;
10
+ --animate-float: float 3s ease-in-out infinite;
11
+ --animate-twirl: twirl 20s ease-in-out infinite;
12
+ --animate-aurora: aurora 20s ease-in-out infinite;
13
+ --animate-gradient-flow: gradient-flow 6s linear infinite;
10
14
  }
11
15
 
12
- .ball {
13
- background: radial-gradient(
14
- circle at 30% 30%,
15
- #454565 0%,
16
- #1c1c30 40%,
17
- #0a0a10 100%
18
- );
19
- border-radius: 50%;
20
- width: 12rem;
21
- height: 12rem;
22
- display: flex;
23
- flex-direction: column;
24
- align-items: center;
25
- justify-content: center;
26
- font-family: monospace;
27
- text-align: center;
28
- position: relative;
29
- box-shadow:
30
- 0 10px 30px rgba(0, 0, 0, 0.5),
31
- 0 5px 15px rgba(0, 0, 0, 0.3),
32
- inset 0 -20px 40px rgba(0, 0, 0, 0.6);
33
- animation:
34
- float 3s ease-in-out infinite,
35
- colorShift 15s ease-in-out infinite;
36
- transition: transform 0.3s ease;
37
- cursor: pointer;
38
- border: 1px solid rgba(30, 30, 50, 0.6);
16
+ @keyframes gradient-flow {
17
+ 0% {
18
+ background-position: 200% 50%;
19
+ }
20
+ 100% {
21
+ background-position: 0% 50%;
22
+ }
39
23
  }
40
24
 
41
- .ball:hover {
42
- transform: scale(1.05) translateY(-8px);
43
- animation: colorShift 15s ease-in-out infinite;
44
- box-shadow:
45
- 0 20px 50px rgba(0, 0, 0, 0.6),
46
- 0 10px 25px rgba(0, 0, 0, 0.4),
47
- inset 0 -20px 40px rgba(0, 0, 0, 0.6);
25
+ @keyframes aurora {
26
+ 0%,
27
+ 100% {
28
+ background-position: 0% 50%;
29
+ }
30
+ 50% {
31
+ background-position: 100% 50%;
32
+ }
48
33
  }
49
34
 
50
35
  @keyframes float {
@@ -53,100 +38,22 @@
53
38
  transform: translateY(0);
54
39
  }
55
40
  50% {
56
- transform: translateY(-8px);
41
+ transform: translateY(-6px);
57
42
  }
58
43
  }
59
44
 
60
- @keyframes colorShift {
45
+ @keyframes twirl {
61
46
  0%,
62
- 100% {
63
- background: radial-gradient(
64
- circle at 30% 30%,
65
- #454565 0%,
66
- #1c1c30 40%,
67
- #0a0a10 100%
68
- );
47
+ 80% {
48
+ transform: rotateY(0deg);
69
49
  }
70
- 25% {
71
- background: radial-gradient(
72
- circle at 30% 30%,
73
- #3f4a65 0%,
74
- #181e30 40%,
75
- #090a10 100%
76
- );
50
+ 85% {
51
+ transform: rotateY(180deg);
77
52
  }
78
- 50% {
79
- background: radial-gradient(
80
- circle at 30% 30%,
81
- #3a5065 0%,
82
- #152230 40%,
83
- #080a10 100%
84
- );
53
+ 95% {
54
+ transform: rotateY(180deg);
85
55
  }
86
- 75% {
87
- background: radial-gradient(
88
- circle at 30% 30%,
89
- #3f4a65 0%,
90
- #181e30 40%,
91
- #090a10 100%
92
- );
56
+ 100% {
57
+ transform: rotateY(360deg);
93
58
  }
94
59
  }
95
-
96
- .ball::before {
97
- content: "";
98
- position: absolute;
99
- top: 8%;
100
- left: 20%;
101
- width: 30%;
102
- height: 20%;
103
- background: radial-gradient(
104
- ellipse,
105
- rgba(255, 255, 255, 0.3) 0%,
106
- transparent 70%
107
- );
108
- border-radius: 50%;
109
- pointer-events: none;
110
- }
111
-
112
- .ball::after {
113
- content: "";
114
- position: absolute;
115
- bottom: 8%;
116
- right: 25%;
117
- width: 25%;
118
- height: 10%;
119
- background: radial-gradient(
120
- ellipse,
121
- rgba(255, 255, 255, 0.1) 0%,
122
- transparent 70%
123
- );
124
- border-radius: 50%;
125
- pointer-events: none;
126
- }
127
-
128
- .question {
129
- font-size: clamp(0.5rem, 2vw, 0.75rem);
130
- color: lightgrey;
131
- max-width: 90%;
132
- word-wrap: break-word;
133
- overflow-wrap: break-word;
134
- text-align: center;
135
- line-height: 1.3;
136
- font-style: italic;
137
- }
138
-
139
- .answer {
140
- font-family: "Playfair Display", serif;
141
- font-style: italic;
142
- font-size: 1.25rem;
143
- font-weight: 600;
144
- margin-top: 0.5rem;
145
- color: #7dd3fc;
146
- text-shadow: 0 0 10px rgba(125, 211, 252, 0.5);
147
- max-width: 90%;
148
- word-wrap: break-word;
149
- overflow-wrap: break-word;
150
- text-align: center;
151
- line-height: 1.3;
152
- }
@@ -1,61 +1,77 @@
1
1
  import { McpServer } from "skybridge/server";
2
2
  import { z } from "zod";
3
3
 
4
- const Answers = [
5
- "As I see it, yes",
6
- "Don't count on it",
7
- "It is certain",
8
- "It is decidedly so",
9
- "Most likely",
10
- "My reply is no",
11
- "My sources say no",
12
- "Outlook good",
13
- "Outlook not so good",
14
- "Signs point to yes",
15
- "Very doubtful",
16
- "Without a doubt",
17
- "Yes definitely",
18
- "Yes",
19
- "You may rely on it",
20
- ];
21
-
22
4
  const server = new McpServer(
23
5
  {
24
6
  name: "alpic-openai-app",
25
7
  version: "0.0.1",
26
8
  },
27
9
  { capabilities: {} },
28
- ).registerTool(
29
- {
30
- name: "magic-8-ball",
31
- description: "For fortune-telling or seeking advice.",
32
- inputSchema: {
33
- question: z.string().describe("The user question."),
34
- },
35
- view: {
36
- component: "magic-8-ball",
37
- description: "Magic 8 Ball",
10
+ )
11
+ .registerTool(
12
+ {
13
+ name: "start",
14
+ description: "Onboard Skybridge",
15
+ inputSchema: {
16
+ name: z.string().optional().describe("The user name."),
17
+ },
18
+ view: {
19
+ component: "onboarding",
20
+ description: "Onboarding deck",
21
+ csp: {
22
+ resourceDomains: [
23
+ "https://fonts.googleapis.com",
24
+ "https://fonts.gstatic.com",
25
+ ],
26
+ redirectDomains: ["https://docs.skybridge.tech"],
27
+ },
28
+ },
38
29
  },
39
- },
40
- async ({ question }) => {
41
- try {
42
- const hash = question
43
- .split("")
44
- .reduce((acc, char) => acc + char.charCodeAt(0), 0);
45
- const answer = Answers[hash % Answers.length];
30
+ async ({ name }) => {
46
31
  return {
47
- structuredContent: { answer },
32
+ structuredContent: { name },
33
+ content: [{ type: "text", text: `User name: ${name}` }],
48
34
  isError: false,
49
35
  };
50
- } catch (error) {
36
+ },
37
+ )
38
+ .registerTool(
39
+ {
40
+ name: "get-fortune-cookie",
41
+ description: "Get fortune cookie",
42
+ },
43
+ async () => {
44
+ const predictions = [
45
+ "A pleasant surprise is waiting for you.",
46
+ "Your hard work will soon pay off.",
47
+ "An unexpected friendship will brighten your week.",
48
+ "The best is yet to come.",
49
+ "A small step today leads to a giant leap tomorrow.",
50
+ "Trust your instincts: they are sharper than you think.",
51
+ "Adventure awaits just around the corner.",
52
+ "A long-forgotten idea will return with great success.",
53
+ "Kindness given today will be returned threefold.",
54
+ "Something you lost will soon be found.",
55
+ ];
56
+ const prediction =
57
+ predictions[Math.floor(Math.random() * predictions.length)];
58
+
59
+ // simulate backend work
60
+ await new Promise((resolve) => setTimeout(resolve, 1000));
61
+
51
62
  return {
52
- content: [{ type: "text", text: `Error: ${error}` }],
53
- isError: true,
63
+ structuredContent: { prediction },
64
+ content: [{ type: "text", text: prediction }],
65
+ isError: false,
54
66
  };
55
- }
56
- },
57
- );
67
+ },
68
+ );
69
+
70
+ if (process.env.NODE_ENV === "production") {
71
+ const { default: manifest } = await import("./vite-manifest.js");
72
+ server.setViteManifest(manifest);
73
+ }
58
74
 
59
- server.run();
75
+ export default await server.run();
60
76
 
61
77
  export type AppType = typeof server;
@@ -0,0 +1,22 @@
1
+ import type { ReactNode } from "react";
2
+ import { useOpenExternal } from "skybridge/web";
3
+
4
+ export default function DocLink({
5
+ href,
6
+ children,
7
+ }: {
8
+ href: string;
9
+ children: ReactNode;
10
+ }) {
11
+ // useOpenExternal: open a URL in a new browser tab from inside the iframe.
12
+ const openExternal = useOpenExternal();
13
+ return (
14
+ <button
15
+ type="button"
16
+ onClick={() => openExternal(href)}
17
+ className="underline underline-offset-4"
18
+ >
19
+ {children}
20
+ </button>
21
+ );
22
+ }
@@ -0,0 +1,21 @@
1
+ import type { ReactNode } from "react";
2
+
3
+ export default function Doc({ children }: { children: ReactNode }) {
4
+ return (
5
+ <p className="flex items-start gap-2 type-text-xs text-muted-foreground mt-auto">
6
+ <svg
7
+ viewBox="0 0 90 90"
8
+ xmlns="http://www.w3.org/2000/svg"
9
+ role="img"
10
+ aria-label="Skybridge"
11
+ className="size-4 shrink-0 mt-0.5"
12
+ >
13
+ <path
14
+ d="M17.2704 89.9987C37.5976 24.3967 65.182 12.9084 89.9996 35.3807V84.1606C89.9996 87.3849 87.3858 89.9987 84.1615 89.9987H17.2704ZM84.1615 0C87.3858 0 89.9996 2.6139 89.9996 5.83819V30.9146C52.0566 -5.26767 14.9006 31.2366 0.000976562 57.6768V5.83819C0.00104114 2.6139 2.61486 2.23904e-08 5.83917 0H84.1615Z"
15
+ fill="currentColor"
16
+ />
17
+ </svg>
18
+ <span>{children}</span>
19
+ </p>
20
+ );
21
+ }
@@ -0,0 +1,31 @@
1
+ import { Button } from "@alpic-ai/ui/components/button";
2
+ import { CheckCheck } from "lucide-react";
3
+
4
+ export default function Nav({
5
+ current,
6
+ total,
7
+ onChange,
8
+ }: {
9
+ current: number;
10
+ total: number;
11
+ onChange: (index: number) => void;
12
+ }) {
13
+ return (
14
+ <div className="flex justify-end gap-2 mt-auto">
15
+ <Button
16
+ variant="secondary"
17
+ disabled={current === 0}
18
+ onClick={() => onChange(Math.max(current - 1, 0))}
19
+ >
20
+ Previous
21
+ </Button>
22
+ <Button
23
+ disabled={current === total - 1}
24
+ onClick={() => onChange(Math.min(current + 1, total - 1))}
25
+ >
26
+ <CheckCheck />
27
+ Next
28
+ </Button>
29
+ </div>
30
+ );
31
+ }
@@ -0,0 +1,35 @@
1
+ import {
2
+ Tooltip,
3
+ TooltipContent,
4
+ TooltipTrigger,
5
+ } from "@alpic-ai/ui/components/tooltip";
6
+
7
+ export default function Progress({
8
+ steps,
9
+ current,
10
+ onSelect,
11
+ }: {
12
+ steps: readonly string[];
13
+ current: number;
14
+ onSelect: (index: number) => void;
15
+ }) {
16
+ return (
17
+ <div className="flex gap-1.5">
18
+ {steps.map((label, i) => (
19
+ <Tooltip key={label}>
20
+ <TooltipTrigger asChild>
21
+ <button
22
+ type="button"
23
+ onClick={() => onSelect(i)}
24
+ className={`relative h-1 flex-1 rounded-full transition-opacity before:absolute before:-inset-y-5 before:inset-x-0 before:content-[''] [@media(hover:hover)]:hover:opacity-70 ${
25
+ i <= current ? "bg-primary" : "bg-muted"
26
+ }`}
27
+ aria-label={label}
28
+ />
29
+ </TooltipTrigger>
30
+ <TooltipContent>{label}</TooltipContent>
31
+ </Tooltip>
32
+ ))}
33
+ </div>
34
+ );
35
+ }
@@ -0,0 +1,68 @@
1
+ import {
2
+ Card,
3
+ CardContent,
4
+ CardDescription,
5
+ CardTitle,
6
+ } from "@alpic-ai/ui/components/card";
7
+ import { BookOpen, CircleStar } from "lucide-react";
8
+ import { useOpenExternal } from "skybridge/web";
9
+
10
+ const LINKS = [
11
+ {
12
+ icon: CircleStar,
13
+ title: "See the examples",
14
+ description:
15
+ "Templates for OAuth, e-commerce, dashboards, games, and many more.",
16
+ href: "https://docs.skybridge.tech/showcase#examples",
17
+ },
18
+ {
19
+ icon: BookOpen,
20
+ title: "Read the docs",
21
+ description: "Learn more about Skybridge concepts, API, and tooling.",
22
+ href: "https://docs.skybridge.tech",
23
+ },
24
+ ];
25
+
26
+ export default function Outro() {
27
+ // useOpenExternal: open a URL in a new browser tab from inside the iframe.
28
+ const openExternal = useOpenExternal();
29
+
30
+ return (
31
+ <>
32
+ <div className="flex flex-1 flex-col justify-center gap-3">
33
+ <h1 className="type-display-xs font-mozilla font-semibold text-primary">
34
+ That's a wrap!
35
+ </h1>
36
+ <p>
37
+ You've just mastered how{" "}
38
+ <strong>
39
+ the data flows between the tools, the view, and the model
40
+ </strong>
41
+ . You can start{" "}
42
+ <span className="bg-gradient-to-r from-primary via-cyan-500 to-primary bg-[length:200%_100%] bg-clip-text text-transparent font-semibold animate-gradient-flow">
43
+ vibing
44
+ </span>{" "}
45
+ now from this very template or:
46
+ </p>
47
+ </div>
48
+ <div className="grid grid-cols-2 gap-3 mt-auto">
49
+ {LINKS.map(({ icon: Icon, title, description, href }) => (
50
+ <Card
51
+ key={title}
52
+ hoverable
53
+ className="cursor-pointer bg-white/50 dark:bg-zinc-900/50"
54
+ onClick={() => openExternal(href)}
55
+ >
56
+ <CardContent className="flex flex-col gap-2">
57
+ <div className="flex items-center gap-3">
58
+ <Icon className="size-5 shrink-0 text-primary" />
59
+ <CardTitle>{title}</CardTitle>
60
+ </div>
61
+ <CardDescription>{description}</CardDescription>
62
+ </CardContent>
63
+ </Card>
64
+ ))}
65
+ </div>
66
+ </>
67
+ );
68
+ }
@@ -0,0 +1,47 @@
1
+ import { Button } from "@alpic-ai/ui/components/button";
2
+ import { HatGlasses } from "lucide-react";
3
+ import Doc from "@/views/components/doc.js";
4
+ import DocLink from "@/views/components/doc-link.js";
5
+ import { useMascot } from "@/views/use-mascot.js";
6
+
7
+ export default function State() {
8
+ const { hat, changeHat } = useMascot();
9
+
10
+ return (
11
+ <>
12
+ <div className="flex flex-1 flex-col justify-center gap-3">
13
+ <p>
14
+ The <strong>view state</strong> can be shared with the model:
15
+ </p>
16
+ <div className="flex">
17
+ <Button variant="cta" onClick={changeHat}>
18
+ <HatGlasses />
19
+ Change my hat
20
+ </Button>
21
+ </div>
22
+ <p className={`mt-2 ${hat ? "" : "invisible"}`} aria-hidden={!hat}>
23
+ Now, the LLM also knows I'm wearing a glorious{" "}
24
+ <span
25
+ // data-llm: describe what the user views to the model so they can collaborate
26
+ data-llm={`Mascot is wearing ${hat}`}
27
+ className="text-primary font-mozilla"
28
+ >
29
+ {hat}
30
+ </span>
31
+ .
32
+ </p>
33
+ </div>
34
+ <Doc>
35
+ Use{" "}
36
+ <DocLink href="https://docs.skybridge.tech/api-reference/use-view-state">
37
+ useViewState
38
+ </DocLink>{" "}
39
+ to update the context and{" "}
40
+ <DocLink href="https://docs.skybridge.tech/api-reference/data-llm">
41
+ data-llm
42
+ </DocLink>{" "}
43
+ to describe the UI.
44
+ </Doc>
45
+ </>
46
+ );
47
+ }
@@ -0,0 +1,53 @@
1
+ import { Button } from "@alpic-ai/ui/components/button";
2
+ import { Cookie } from "lucide-react";
3
+ import { useEffect, useState } from "react";
4
+ import { useCallTool } from "@/helpers.js";
5
+ import Doc from "@/views/components/doc.js";
6
+ import DocLink from "@/views/components/doc-link.js";
7
+
8
+ export default function ToolCall() {
9
+ // useCallTool: invoke a server tool from within the view.
10
+ const { callTool, isPending, data } = useCallTool("get-fortune-cookie");
11
+ const [prediction, setPrediction] = useState<string | null>(null);
12
+
13
+ useEffect(() => {
14
+ if (data) {
15
+ setPrediction(data.structuredContent.prediction);
16
+ }
17
+ }, [data]);
18
+
19
+ return (
20
+ <>
21
+ <div className="flex flex-1 flex-col justify-center gap-3">
22
+ <p className="">
23
+ <strong>Tools</strong> can also be triggered from the view:
24
+ </p>
25
+ <div className="flex">
26
+ <Button
27
+ variant="cta"
28
+ loading={isPending}
29
+ icon={<Cookie />}
30
+ onClick={() => callTool()}
31
+ >
32
+ <code>get-fortune-cookie</code>
33
+ </Button>
34
+ </div>
35
+ <p
36
+ className={`font-mozilla italic text-primary mt-2 ${
37
+ prediction ? "" : "invisible"
38
+ }`}
39
+ aria-hidden={!prediction}
40
+ >
41
+ {prediction || "none"}
42
+ </p>
43
+ </div>
44
+ <Doc>
45
+ Use{" "}
46
+ <DocLink href="https://docs.skybridge.tech/api-reference/use-call-tool">
47
+ useCallTool
48
+ </DocLink>{" "}
49
+ to request tools from within the view.
50
+ </Doc>
51
+ </>
52
+ );
53
+ }
@@ -0,0 +1,40 @@
1
+ import { useToolInfo } from "@/helpers.js";
2
+ import Doc from "@/views/components/doc.js";
3
+ import DocLink from "@/views/components/doc-link.js";
4
+
5
+ export default function ToolOutput() {
6
+ // useToolInfo: read the input, output and metadata of the tool that opened this view.
7
+ const { output } = useToolInfo<"start">();
8
+ const name = output?.name;
9
+
10
+ return (
11
+ <>
12
+ <div className="flex flex-1 flex-col justify-center gap-3">
13
+ <h1 className="type-display-xs font-mozilla font-semibold">
14
+ Greetings,{" "}
15
+ <span className="text-primary">{name ?? "stranger"} !</span>
16
+ </h1>
17
+ {name ? (
18
+ <p>
19
+ You're wondering how do I know your name, don't you? Well, it's
20
+ because the view reads the <strong>tool output</strong>. The LLM
21
+ knows about it too.
22
+ </p>
23
+ ) : (
24
+ <p>
25
+ The view reads the <strong>tool output</strong>, but no{" "}
26
+ <code>name</code> was passed this time. Try again with you surname
27
+ to see with this view personalize.
28
+ </p>
29
+ )}
30
+ </div>
31
+ <Doc>
32
+ Use{" "}
33
+ <DocLink href="https://docs.skybridge.tech/api-reference/use-tool-info">
34
+ useToolInfo
35
+ </DocLink>{" "}
36
+ to hydrates the view with tool input, output and metadata.
37
+ </Doc>
38
+ </>
39
+ );
40
+ }
@@ -0,0 +1,63 @@
1
+ import "@/index.css";
2
+
3
+ import { useState } from "react";
4
+ import { useLayout } from "skybridge/web";
5
+ import Nav from "./components/nav.js";
6
+ import Progress from "./components/progress.js";
7
+ import Outro from "./components/steps/outro.js";
8
+ import State from "./components/steps/state.js";
9
+ import ToolCall from "./components/steps/tool-call.js";
10
+ import ToolOutput from "./components/steps/tool-output.js";
11
+ import { useMascot } from "./use-mascot.js";
12
+
13
+ const STEPS = [
14
+ { label: "Reading tool output", Component: ToolOutput },
15
+ { label: "Sharing view state", Component: State },
16
+ { label: "Calling tools", Component: ToolCall },
17
+ { label: "Examples & docs", Component: Outro },
18
+ ] as const;
19
+
20
+ export default function Onboarding() {
21
+ // useLayout: read host layout info (theme, display mode, locale, ...).
22
+ const { theme } = useLayout();
23
+
24
+ const [step, setStep] = useState(0);
25
+ const { img } = useMascot();
26
+
27
+ return (
28
+ <div
29
+ className={`${theme === "dark" ? "dark" : ""} mx-auto w-full max-w-4xl rounded-xl border border-border overflow-hidden bg-background text-foreground`}
30
+ >
31
+ <div className="min-h-[34rem] md:min-h-95 flex flex-col items-center gap-6 p-6 bg-gradient-to-br from-purple-50 via-white to-cyan-50 dark:from-purple-950/30 dark:via-zinc-950 dark:to-cyan-900/30 bg-[length:200%_200%] animate-aurora md:flex-row md:items-stretch">
32
+ <div className="shrink-0 self-center animate-float">
33
+ <img
34
+ src={img}
35
+ alt="Skybridge mascot"
36
+ className="h-32 w-32 md:h-50 md:w-50 object-contain animate-twirl"
37
+ />
38
+ </div>
39
+ <div className="flex w-full flex-1 flex-col gap-6">
40
+ <Progress
41
+ steps={STEPS.map(({ label }) => label)}
42
+ current={step}
43
+ onSelect={setStep}
44
+ />
45
+ <div className="grid flex-1">
46
+ {STEPS.map(({ label, Component }, i) => (
47
+ <div
48
+ key={label}
49
+ className={`col-start-1 row-start-1 flex flex-col gap-6 ${
50
+ step === i ? "" : "invisible pointer-events-none"
51
+ }`}
52
+ aria-hidden={step !== i}
53
+ >
54
+ <Component />
55
+ </div>
56
+ ))}
57
+ </div>
58
+ <Nav current={step} total={STEPS.length} onChange={setStep} />
59
+ </div>
60
+ </div>
61
+ </div>
62
+ );
63
+ }
@@ -0,0 +1,60 @@
1
+ import { useEffect } from "react";
2
+ import { useViewState } from "skybridge/web";
3
+ import beret from "./images/mascot/beret.png";
4
+ import chapka from "./images/mascot/chapka.png";
5
+ import cowboyHat from "./images/mascot/cowboy-hat.png";
6
+ import fez from "./images/mascot/fez.png";
7
+ import jesterHat from "./images/mascot/jester-hat.png";
8
+ import mitre from "./images/mascot/mitre.png";
9
+ import nonLa from "./images/mascot/non-la.png";
10
+ import original from "./images/mascot/original.png";
11
+ import propellerBeanie from "./images/mascot/propeller-beanie.png";
12
+ import skiMask from "./images/mascot/ski-mask.png";
13
+ import sombrero from "./images/mascot/sombrero.png";
14
+ import topHat from "./images/mascot/top-hat.png";
15
+ import vikingHelmet from "./images/mascot/viking-helmet.png";
16
+
17
+ const Hats = {
18
+ beret,
19
+ chapka,
20
+ "cowboy hat": cowboyHat,
21
+ fez,
22
+ "jester hat": jesterHat,
23
+ mitre,
24
+ "nón lá": nonLa,
25
+ "propeller beanie": propellerBeanie,
26
+ "ski mask": skiMask,
27
+ sombrero,
28
+ "top hat": topHat,
29
+ "viking helmet": vikingHelmet,
30
+ } as const;
31
+
32
+ type HatLabel = keyof typeof Hats;
33
+
34
+ const LABELS = Object.keys(Hats) as HatLabel[];
35
+
36
+ export function useMascot() {
37
+ // useViewState: persist UI state on the host and surface it to the model.
38
+ const [state, setState] = useViewState<{ hat?: HatLabel }>({});
39
+ const { hat } = state;
40
+ const img = hat ? Hats[hat] : original;
41
+
42
+ // Preload all hats once so swaps are instant.
43
+ useEffect(() => {
44
+ for (const src of Object.values(Hats)) {
45
+ new Image().src = src;
46
+ }
47
+ }, []);
48
+
49
+ return {
50
+ img,
51
+ hat,
52
+ changeHat: () => {
53
+ setState((prev) => {
54
+ const others = LABELS.filter((l) => l !== prev.hat);
55
+ const next = others[Math.floor(Math.random() * others.length)];
56
+ return { ...prev, hat: next };
57
+ });
58
+ },
59
+ };
60
+ }
@@ -0,0 +1,4 @@
1
+ // Typed shim for the Vite manifest emitted by `skybridge build`. The actual
2
+ // `vite-manifest.js` is generated alongside this file and gitignored.
3
+ declare const manifest: Record<string, { file: string }>;
4
+ export default manifest;
@@ -1,10 +1,11 @@
1
1
  import path from "node:path";
2
+ import tailwindcss from "@tailwindcss/vite";
2
3
  import react from "@vitejs/plugin-react";
3
4
  import { skybridge } from "skybridge/vite";
4
5
  import { defineConfig } from "vite";
5
6
 
6
7
  export default defineConfig({
7
- plugins: [skybridge(), react()],
8
+ plugins: [skybridge(), react(), tailwindcss()],
8
9
  resolve: {
9
10
  alias: {
10
11
  "@": path.resolve(__dirname, "./src"),
@@ -1,22 +0,0 @@
1
- export function Ball({
2
- question,
3
- answer,
4
- }: {
5
- question?: string;
6
- answer?: string;
7
- }) {
8
- return (
9
- <div className="container">
10
- <div className="ball">
11
- {answer ? (
12
- <>
13
- <div className="question">{question}</div>
14
- <div className="answer">{answer}</div>
15
- </>
16
- ) : (
17
- <div className="question">Shaking...</div>
18
- )}
19
- </div>
20
- </div>
21
- );
22
- }
@@ -1,10 +0,0 @@
1
- import "@/index.css";
2
-
3
- import { Ball } from "../components/ball.js";
4
- import { useToolInfo } from "../helpers.js";
5
-
6
- export default function Magic8Ball() {
7
- const { input, output } = useToolInfo<"magic-8-ball">();
8
-
9
- return <Ball question={input?.question} answer={output?.answer} />;
10
- }