skybridge 0.0.0-dev.d6a0040 → 0.0.0-dev.d6c0321
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/dist/src/server/server.d.ts +0 -3
- package/dist/src/server/server.js +31 -42
- package/dist/src/server/server.js.map +1 -1
- package/dist/src/server/templates/development.hbs +1 -1
- package/dist/src/test/widget.test.js +1 -18
- package/dist/src/test/widget.test.js.map +1 -1
- package/dist/src/web/plugin/plugin.js +4 -10
- package/dist/src/web/plugin/plugin.js.map +1 -1
- package/package.json +11 -15
- package/README.md +0 -123
|
@@ -57,9 +57,6 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
57
57
|
}, toolCallback: ToolHandler<TInput, TReturn>): AddTool<TTools, TName, TInput, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
58
58
|
registerTool<TName extends string, InputArgs extends ZodRawShapeCompat, TReturn extends CallToolResult>(name: TName, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs, TReturn>): AddTool<TTools, TName, InputArgs, ExtractStructuredContent<TReturn>, ExtractMeta<TReturn>>;
|
|
59
59
|
registerTool<InputArgs extends ZodRawShapeCompat>(name: string, config: ToolConfig<InputArgs>, cb: ToolHandler<InputArgs>): RegisteredTool;
|
|
60
|
-
private registerWidgetResource;
|
|
61
60
|
private lookupDistFile;
|
|
62
|
-
private lookupDistFileWithIndexFallback;
|
|
63
|
-
private readManifest;
|
|
64
61
|
}
|
|
65
62
|
export {};
|
|
@@ -4,32 +4,45 @@ import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mc
|
|
|
4
4
|
import { templateHelper } from "./templateHelper.js";
|
|
5
5
|
export class McpServer extends McpServerBase {
|
|
6
6
|
registerWidget(name, resourceConfig, toolConfig, toolCallback) {
|
|
7
|
+
const uri = `ui://widgets/${name}.html`;
|
|
7
8
|
const resourceMetadata = {
|
|
8
9
|
...(resourceConfig._meta ?? {}),
|
|
9
10
|
};
|
|
10
11
|
if (toolConfig.description !== undefined) {
|
|
11
12
|
resourceMetadata["openai/widgetDescription"] = toolConfig.description;
|
|
12
13
|
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
14
|
+
this.registerResource(name, uri, {
|
|
15
|
+
...resourceConfig,
|
|
16
|
+
_meta: resourceMetadata,
|
|
17
|
+
}, async (_uri, extra) => {
|
|
18
|
+
const serverUrl = process.env.NODE_ENV === "production"
|
|
19
|
+
? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ??
|
|
20
|
+
extra?.requestInfo?.headers?.host}`
|
|
21
|
+
: `http://localhost:3000`;
|
|
22
|
+
const html = process.env.NODE_ENV === "production"
|
|
23
|
+
? templateHelper.renderProduction({
|
|
24
|
+
serverUrl,
|
|
25
|
+
widgetFile: this.lookupDistFile(`src/widgets/${name}.tsx`),
|
|
26
|
+
styleFile: this.lookupDistFile("style.css"),
|
|
27
|
+
})
|
|
28
|
+
: templateHelper.renderDevelopment({
|
|
29
|
+
serverUrl,
|
|
30
|
+
widgetName: name,
|
|
31
|
+
});
|
|
32
|
+
return {
|
|
33
|
+
contents: [
|
|
34
|
+
{
|
|
35
|
+
uri,
|
|
36
|
+
mimeType: "text/html+skybridge",
|
|
37
|
+
text: html,
|
|
38
|
+
},
|
|
39
|
+
],
|
|
40
|
+
};
|
|
28
41
|
});
|
|
29
42
|
const toolMeta = {
|
|
30
43
|
...toolConfig._meta,
|
|
31
|
-
"openai/outputTemplate":
|
|
32
|
-
"ui/resourceUri":
|
|
44
|
+
"openai/outputTemplate": uri,
|
|
45
|
+
"ui/resourceUri": uri,
|
|
33
46
|
};
|
|
34
47
|
this.registerTool(name, {
|
|
35
48
|
...toolConfig,
|
|
@@ -41,33 +54,9 @@ export class McpServer extends McpServerBase {
|
|
|
41
54
|
super.registerTool(name, config, cb);
|
|
42
55
|
return this;
|
|
43
56
|
}
|
|
44
|
-
registerWidgetResource({ name, uri, mimeType, resourceConfig, resourceMetadata, }) {
|
|
45
|
-
this.registerResource(name, uri, { ...resourceConfig, _meta: resourceMetadata }, async (_uri, extra) => {
|
|
46
|
-
const serverUrl = process.env.NODE_ENV === "production"
|
|
47
|
-
? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ?? extra?.requestInfo?.headers?.host}`
|
|
48
|
-
: `http://localhost:3000`;
|
|
49
|
-
const html = process.env.NODE_ENV === "production"
|
|
50
|
-
? templateHelper.renderProduction({
|
|
51
|
-
serverUrl,
|
|
52
|
-
widgetFile: this.lookupDistFileWithIndexFallback(`src/widgets/${name}.tsx`),
|
|
53
|
-
styleFile: this.lookupDistFile("style.css"),
|
|
54
|
-
})
|
|
55
|
-
: templateHelper.renderDevelopment({ serverUrl, widgetName: name });
|
|
56
|
-
return { contents: [{ uri, mimeType, text: html }] };
|
|
57
|
-
});
|
|
58
|
-
}
|
|
59
57
|
lookupDistFile(key) {
|
|
60
|
-
const manifest =
|
|
58
|
+
const manifest = JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
61
59
|
return manifest[key]?.file;
|
|
62
60
|
}
|
|
63
|
-
lookupDistFileWithIndexFallback(basePath) {
|
|
64
|
-
const manifest = this.readManifest();
|
|
65
|
-
const flatFileKey = `${basePath}.tsx`;
|
|
66
|
-
const indexFileKey = `${basePath}/index.tsx`;
|
|
67
|
-
return manifest[flatFileKey]?.file ?? manifest[indexFileKey]?.file;
|
|
68
|
-
}
|
|
69
|
-
readManifest() {
|
|
70
|
-
return JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
71
|
-
}
|
|
72
61
|
}
|
|
73
62
|
//# sourceMappingURL=server.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,SAAS,IAAI,aAAa,GAG3B,MAAM,yCAAyC,CAAC;AAcjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA0HrD,MAAM,OAAO,SAEX,SAAQ,aAAa;IAGrB,cAAc,CAKZ,IAAW,EACX,cAA+C,EAC/C,UAGC,EACD,YAA0C;QAQ1C,MAAM,gBAAgB,GAAiB;YACrC,GAAG,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC;SAChC,CAAC;QACF,IAAI,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACzC,gBAAgB,CAAC,0BAA0B,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;QACxE,CAAC;QAED,
|
|
1
|
+
{"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EACL,SAAS,IAAI,aAAa,GAG3B,MAAM,yCAAyC,CAAC;AAcjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA0HrD,MAAM,OAAO,SAEX,SAAQ,aAAa;IAGrB,cAAc,CAKZ,IAAW,EACX,cAA+C,EAC/C,UAGC,EACD,YAA0C;QAQ1C,MAAM,GAAG,GAAG,gBAAgB,IAAI,OAAO,CAAC;QACxC,MAAM,gBAAgB,GAAiB;YACrC,GAAG,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC;SAChC,CAAC;QACF,IAAI,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACzC,gBAAgB,CAAC,0BAA0B,CAAC,GAAG,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,EACZ,MAA6B,EAC7B,EAA2B;QAE3B,KAAK,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAC,CAAC;QACrC,OAAO,IAAI,CAAC;IACd,CAAC;IAEO,cAAc,CAAC,GAAW;QAChC,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CACzB,YAAY,CACV,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,CAAC,EACpE,OAAO,CACR,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAC7B,CAAC;CACF"}
|
|
@@ -2,7 +2,6 @@ import { afterEach, beforeEach, describe, expect, it, vi, } from "vitest";
|
|
|
2
2
|
import { createMockExtra, createMockMcpServer, resetTestEnv, setTestEnv, } from "./utils.js";
|
|
3
3
|
const mockManifest = {
|
|
4
4
|
"src/widgets/my-widget.tsx": { file: "my-widget.js" },
|
|
5
|
-
"src/widgets/folder-widget/index.tsx": { file: "folder-widget.js" },
|
|
6
5
|
"style.css": { file: "style.css" },
|
|
7
6
|
};
|
|
8
7
|
vi.mock("node:fs", async () => {
|
|
@@ -62,8 +61,7 @@ describe("McpServer.registerWidget", () => {
|
|
|
62
61
|
// Check development-specific content
|
|
63
62
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/@react-refresh`);
|
|
64
63
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/@vite/client`);
|
|
65
|
-
expect(result.contents[0]?.text).toContain(`${serverUrl}/src/widgets/my-widget`);
|
|
66
|
-
expect(result.contents[0]?.text).not.toContain(`${serverUrl}/src/widgets/my-widget.tsx`);
|
|
64
|
+
expect(result.contents[0]?.text).toContain(`${serverUrl}/src/widgets/my-widget.tsx`);
|
|
67
65
|
});
|
|
68
66
|
it("should generate correct HTML for production mode", async () => {
|
|
69
67
|
setTestEnv({ NODE_ENV: "production" });
|
|
@@ -93,20 +91,5 @@ describe("McpServer.registerWidget", () => {
|
|
|
93
91
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/my-widget.js`);
|
|
94
92
|
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/style.css`);
|
|
95
93
|
});
|
|
96
|
-
it("should resolve folder-based widgets (barrel files) in production mode", async () => {
|
|
97
|
-
setTestEnv({ NODE_ENV: "production" });
|
|
98
|
-
const mockToolCallback = vi.fn();
|
|
99
|
-
const mockRegisterResourceConfig = { description: "Folder widget" };
|
|
100
|
-
const mockToolConfig = { description: "Folder tool" };
|
|
101
|
-
server.registerWidget("folder-widget", mockRegisterResourceConfig, mockToolConfig, mockToolCallback);
|
|
102
|
-
const resourceCallback = mockRegisterResource.mock
|
|
103
|
-
.calls[0]?.[3];
|
|
104
|
-
expect(resourceCallback).toBeDefined();
|
|
105
|
-
const serverUrl = "https://myapp.com";
|
|
106
|
-
const mockExtra = createMockExtra(serverUrl);
|
|
107
|
-
const result = await resourceCallback(new URL("ui://widgets/folder-widget.html"), mockExtra);
|
|
108
|
-
// Should resolve to folder-widget.js from the manifest entry "src/widgets/folder-widget/index.tsx"
|
|
109
|
-
expect(result.contents[0]?.text).toContain(`${serverUrl}/assets/folder-widget.js`);
|
|
110
|
-
});
|
|
111
94
|
});
|
|
112
95
|
//# sourceMappingURL=widget.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"widget.test.js","sourceRoot":"","sources":["../../../src/test/widget.test.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,SAAS,EACT,UAAU,EACV,QAAQ,EACR,MAAM,EACN,EAAE,EAEF,EAAE,GACH,MAAM,QAAQ,CAAC;AAEhB,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,YAAY,EACZ,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,MAAM,YAAY,GAAG;IACnB,2BAA2B,EAAE,EAAE,IAAI,EAAE,cAAc,EAAE;IACrD,
|
|
1
|
+
{"version":3,"file":"widget.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R;oBACE,GAAG,EAAE,6BAA6B;oBAClC,QAAQ,EAAE,qBAAqB;oBAC/B,IAAI,EAAE,MAAM,CAAC,gBAAgB,CAAC,uBAAuB,CAAC;iBACvD;aACF;SACF,CAAC,CAAC;QAEH,oCAAoC;QACpC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CAC5C,GAAG,SAAS,gBAAgB,CAC7B,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,GAAG,SAAS,cAAc,CAAC,CAAC;QAC3E,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,CACxC,GAAG,SAAS,sBAAsB,CACnC,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,GAAG,SAAS,mBAAmB,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -7,17 +7,11 @@ export function skybridge() {
|
|
|
7
7
|
const { globSync } = await import("node:fs");
|
|
8
8
|
const { resolve } = await import("node:path");
|
|
9
9
|
const projectRoot = config.root || process.cwd();
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
file.match(/src\/widgets\/([^/]+)\.tsx$/)?.[1],
|
|
10
|
+
const widgetsPattern = resolve(projectRoot, "src/widgets/*.{js,ts,jsx,tsx,html}");
|
|
11
|
+
const input = Object.fromEntries(globSync(widgetsPattern).map((file) => [
|
|
12
|
+
file.match(/src\/widgets\/(.+)\.tsx$/)?.[1],
|
|
14
13
|
file,
|
|
15
|
-
]);
|
|
16
|
-
const dirWidgets = globSync(dirWidgetPattern).map((file) => [
|
|
17
|
-
file.match(/src\/widgets\/([^/]+)\/index\.tsx$/)?.[1],
|
|
18
|
-
file,
|
|
19
|
-
]);
|
|
20
|
-
const input = Object.fromEntries([...flatWidgets, ...dirWidgets]);
|
|
14
|
+
]));
|
|
21
15
|
return {
|
|
22
16
|
base: "/assets",
|
|
23
17
|
build: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../src/web/plugin/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAExE,MAAM,UAAU,SAAS;IACvB,OAAO;QACL,IAAI,EAAE,WAAW;QAEjB,KAAK,CAAC,MAAM,CAAC,MAAM;YACjB,4EAA4E;YAC5E,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;YAC7C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;YAE9C,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YACjD,MAAM,
|
|
1
|
+
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../../src/web/plugin/plugin.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,IAAI,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAExE,MAAM,UAAU,SAAS;IACvB,OAAO;QACL,IAAI,EAAE,WAAW;QAEjB,KAAK,CAAC,MAAM,CAAC,MAAM;YACjB,4EAA4E;YAC5E,MAAM,EAAE,QAAQ,EAAE,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC;YAC7C,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,CAAC;YAE9C,MAAM,WAAW,GAAG,MAAM,CAAC,IAAI,IAAI,OAAO,CAAC,GAAG,EAAE,CAAC;YACjD,MAAM,cAAc,GAAG,OAAO,CAC5B,WAAW,EACX,oCAAoC,CACrC,CAAC;YAEF,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAC9B,QAAQ,CAAC,cAAc,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC;gBACrC,IAAI,CAAC,KAAK,CAAC,0BAA0B,CAAC,EAAE,CAAC,CAAC,CAAC;gBAC3C,IAAI;aACL,CAAC,CACH,CAAC;YAEF,OAAO;gBACL,IAAI,EAAE,SAAS;gBACf,KAAK,EAAE;oBACL,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE,IAAI;oBACZ,YAAY,EAAE,KAAK;oBACnB,aAAa,EAAE;wBACb,KAAK;qBACN;iBACF;aACF,CAAC;QACJ,CAAC;QACD,OAAO,EAAE,KAAK;QACd,KAAK,CAAC,SAAS,CAAC,IAAI,EAAE,EAAE;YACtB,OAAO,MAAM,gBAAgB,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;QAC1C,CAAC;KACF,CAAC;AACJ,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skybridge",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.d6c0321",
|
|
4
4
|
"description": "Skybridge is a framework for building ChatGPT apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -16,18 +16,6 @@
|
|
|
16
16
|
"default": "./dist/src/web/index.js"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
-
"scripts": {
|
|
20
|
-
"build": "tsc && pnpm run build:templates",
|
|
21
|
-
"build:templates": "cp -r src/server/templates dist/src/server/",
|
|
22
|
-
"format": "biome check --write --error-on-warnings",
|
|
23
|
-
"test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
|
|
24
|
-
"test:unit": "vitest run",
|
|
25
|
-
"test:type": "tsc --noEmit",
|
|
26
|
-
"test:format": "biome ci",
|
|
27
|
-
"docs:dev": "pnpm --filter @skybridge/docs start",
|
|
28
|
-
"docs:build": "pnpm --filter @skybridge/docs build",
|
|
29
|
-
"docs:serve": "pnpm --filter @skybridge/docs serve"
|
|
30
|
-
},
|
|
31
19
|
"keywords": [
|
|
32
20
|
"chatgpt",
|
|
33
21
|
"app",
|
|
@@ -69,5 +57,13 @@
|
|
|
69
57
|
"vitest": "^2.1.8",
|
|
70
58
|
"zod": "^4.1.13"
|
|
71
59
|
},
|
|
72
|
-
"
|
|
73
|
-
|
|
60
|
+
"scripts": {
|
|
61
|
+
"build": "tsc && pnpm run build:templates",
|
|
62
|
+
"build:templates": "cp -r src/server/templates dist/src/server/",
|
|
63
|
+
"format": "biome check --write --error-on-warnings",
|
|
64
|
+
"test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
|
|
65
|
+
"test:unit": "vitest run",
|
|
66
|
+
"test:type": "tsc --noEmit",
|
|
67
|
+
"test:format": "biome ci"
|
|
68
|
+
}
|
|
69
|
+
}
|
package/README.md
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
<img alt="Skybridge" src="docs/static/img/logo.png" width="220">
|
|
4
|
-
|
|
5
|
-
# Skybridge
|
|
6
|
-
|
|
7
|
-
**Build ChatGPT Apps. The Modern TypeScript Way.**
|
|
8
|
-
|
|
9
|
-
The fullstack TypeScript framework for ChatGPT Apps.<br />
|
|
10
|
-
**Type-safe. React-powered. Zero config.**
|
|
11
|
-
|
|
12
|
-
<br />
|
|
13
|
-
|
|
14
|
-
[](https://www.npmjs.com/package/skybridge)
|
|
15
|
-
[](https://www.npmjs.com/package/skybridge)
|
|
16
|
-
[](https://github.com/alpic-ai/skybridge/blob/main/LICENSE)
|
|
17
|
-
|
|
18
|
-
<br />
|
|
19
|
-
|
|
20
|
-
[Documentation](https://skybridge.tech) · [Quick Start](https://github.com/new?template_name=apps-sdk-template&template_owner=alpic-ai) · [Examples](https://github.com/alpic-ai/apps-sdk-template)
|
|
21
|
-
|
|
22
|
-
</div>
|
|
23
|
-
|
|
24
|
-
<br />
|
|
25
|
-
|
|
26
|
-
## ✨ Why Skybridge?
|
|
27
|
-
|
|
28
|
-
ChatGPT Apps let you embed **rich, interactive UIs** directly in conversations. But the raw SDK is low-level—no hooks, no type safety, no dev tools, and no HMR.
|
|
29
|
-
|
|
30
|
-
**Skybridge fixes that.**
|
|
31
|
-
|
|
32
|
-
| | |
|
|
33
|
-
|:--|:--|
|
|
34
|
-
| 👨💻 **Full Dev Environment** — HMR, debug traces, and local devtools. No more refresh loops. | ✅ **End-to-End Type Safety** — tRPC-style inference from server to widget. Autocomplete everywhere. |
|
|
35
|
-
| 🔄 **Widget-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
|
-
|
|
37
|
-
<br />
|
|
38
|
-
|
|
39
|
-
## 🚀 Get Started
|
|
40
|
-
|
|
41
|
-
**Create a new ChatGPT app:**
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
gh repo create my-app --template alpic-ai/apps-sdk-template --clone
|
|
45
|
-
cd my-app && pnpm install
|
|
46
|
-
```
|
|
47
|
-
|
|
48
|
-
**Or add to an existing project:**
|
|
49
|
-
|
|
50
|
-
```bash
|
|
51
|
-
npm i skybridge
|
|
52
|
-
yarn add skybridge
|
|
53
|
-
pnpm add skybridge
|
|
54
|
-
bun add skybridge
|
|
55
|
-
deno add skybridge
|
|
56
|
-
```
|
|
57
|
-
|
|
58
|
-
<div align="center">
|
|
59
|
-
|
|
60
|
-
**👉 [Read the Docs](https://skybridge.tech) 👈**
|
|
61
|
-
|
|
62
|
-
</div>
|
|
63
|
-
|
|
64
|
-
<br />
|
|
65
|
-
|
|
66
|
-
## 📦 The Stack
|
|
67
|
-
|
|
68
|
-
- **`skybridge/server`** — Drop-in MCP SDK replacement with widget registration and type inference.
|
|
69
|
-
- **`skybridge/web`** — React hooks and components for ChatGPT's runtime.
|
|
70
|
-
|
|
71
|
-
### Server
|
|
72
|
-
|
|
73
|
-
```ts
|
|
74
|
-
import { McpServer } from "skybridge/server";
|
|
75
|
-
|
|
76
|
-
server.registerWidget("flights", {}, {
|
|
77
|
-
inputSchema: { destination: z.string() },
|
|
78
|
-
}, async ({ destination }) => {
|
|
79
|
-
const flights = await searchFlights(destination);
|
|
80
|
-
return { structuredContent: { flights } };
|
|
81
|
-
});
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
### Widget
|
|
85
|
-
|
|
86
|
-
```tsx
|
|
87
|
-
import { useToolInfo } from "skybridge/web";
|
|
88
|
-
|
|
89
|
-
function FlightsWidget() {
|
|
90
|
-
const { output } = useToolInfo();
|
|
91
|
-
|
|
92
|
-
return output.structuredContent.flights.map(f =>
|
|
93
|
-
<FlightCard key={f.id} flight={f} />
|
|
94
|
-
);
|
|
95
|
-
}
|
|
96
|
-
```
|
|
97
|
-
|
|
98
|
-
<br />
|
|
99
|
-
|
|
100
|
-
## 🎯 Features at a Glance
|
|
101
|
-
|
|
102
|
-
- **Live Reload** — Vite HMR. See changes instantly without reinstalling.
|
|
103
|
-
- **Typed Hooks** — Full autocomplete for tools, inputs, outputs.
|
|
104
|
-
- **Widget → Tool Calls** — Trigger server actions from UI.
|
|
105
|
-
- **Dual Surface Sync** — Keep model aware of what users see with `data-llm`.
|
|
106
|
-
- **React Query-style API** — `isPending`, `isError`, callbacks.
|
|
107
|
-
- **MCP Compatible** — Extends the official SDK. Works with any MCP client.
|
|
108
|
-
|
|
109
|
-
<br />
|
|
110
|
-
|
|
111
|
-
<div align="center">
|
|
112
|
-
|
|
113
|
-
[](https://github.com/alpic-ai/skybridge/discussions)
|
|
114
|
-
[](https://github.com/alpic-ai/skybridge/issues)
|
|
115
|
-
[](https://discord.com/invite/gNAazGueab)
|
|
116
|
-
|
|
117
|
-
See [CONTRIBUTING.md](CONTRIBUTING.md) for setup instructions
|
|
118
|
-
|
|
119
|
-
<br />
|
|
120
|
-
|
|
121
|
-
**[MIT License](LICENSE)** · Made with ❤️ by **[Alpic](https://alpic.ai)**
|
|
122
|
-
|
|
123
|
-
</div>
|