skybridge 0.0.0-dev.da10bf6 → 0.0.0-dev.df1e499
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/devtoolsStaticServer.js +9 -4
- package/dist/src/server/devtoolsStaticServer.js.map +1 -1
- package/dist/src/server/server.d.ts +0 -2
- package/dist/src/server/server.js +2 -11
- 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 +2 -5
- package/LICENSE +0 -21
- package/README.md +0 -123
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { readFileSync } from "node:fs";
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { createRequire } from "node:module";
|
|
2
3
|
import path from "node:path";
|
|
3
|
-
import { fileURLToPath } from "node:url";
|
|
4
4
|
import cors from "cors";
|
|
5
5
|
import express, {} from "express";
|
|
6
|
+
const require = createRequire(import.meta.url);
|
|
6
7
|
/**
|
|
7
8
|
* Serve the built devtools React app
|
|
8
9
|
* This router serves static files from the devtools's dist directory.
|
|
@@ -18,8 +19,12 @@ import express, {} from "express";
|
|
|
18
19
|
*/
|
|
19
20
|
export const devtoolsStaticServer = async () => {
|
|
20
21
|
const router = express.Router();
|
|
21
|
-
|
|
22
|
-
const
|
|
22
|
+
let devtoolsPath;
|
|
23
|
+
const devtoolsPackagePath = require.resolve("@skybridge/devtools/package.json");
|
|
24
|
+
devtoolsPath = path.join(path.dirname(devtoolsPackagePath), "dist");
|
|
25
|
+
if (!existsSync(devtoolsPath)) {
|
|
26
|
+
throw new Error("@skybridge/devtools dist folder not found. The package is installed but not built. Please build it first.");
|
|
27
|
+
}
|
|
23
28
|
router.use(cors());
|
|
24
29
|
router.use(express.static(devtoolsPath));
|
|
25
30
|
router.get("/", (_req, res, next) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"devtoolsStaticServer.js","sourceRoot":"","sources":["../../../src/server/devtoolsStaticServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"devtoolsStaticServer.js","sourceRoot":"","sources":["../../../src/server/devtoolsStaticServer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACnD,OAAO,EAAE,aAAa,EAAE,MAAM,aAAa,CAAC;AAC5C,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,OAAO,EAAE,EAAuB,MAAM,SAAS,CAAC;AAEvD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAE/C;;;;;;;;;;;;GAYG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG,KAAK,IAA6B,EAAE;IACtE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAChC,IAAI,YAAoB,CAAC;IACzB,MAAM,mBAAmB,GAAG,OAAO,CAAC,OAAO,CACzC,kCAAkC,CACnC,CAAC;IACF,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,MAAM,CAAC,CAAC;IAEpE,IAAI,CAAC,UAAU,CAAC,YAAY,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CACb,2GAA2G,CAC5G,CAAC;IACJ,CAAC;IAED,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,CAAC;IAEnB,MAAM,CAAC,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAEzC,MAAM,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;QAClC,MAAM,aAAa,GAAG,IAAI,CAAC,IAAI,CAAC,YAAY,EAAE,YAAY,CAAC,CAAC;QAC5D,IAAI,CAAC;YACH,MAAM,SAAS,GAAG,YAAY,CAAC,aAAa,EAAE,OAAO,CAAC,CAAC;YACvD,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,WAAW,CAAC,CAAC;YAC3C,GAAG,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QACtB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,CAAC,KAAK,CAAC,CAAC;QACd,CAAC;IACH,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC"}
|
|
@@ -58,7 +58,5 @@ export declare class McpServer<TTools extends Record<string, ToolDef> = Record<n
|
|
|
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
60
|
private lookupDistFile;
|
|
61
|
-
private lookupDistBarrelFile;
|
|
62
|
-
private readManifest;
|
|
63
61
|
}
|
|
64
62
|
export {};
|
|
@@ -22,7 +22,7 @@ export class McpServer extends McpServerBase {
|
|
|
22
22
|
const html = process.env.NODE_ENV === "production"
|
|
23
23
|
? templateHelper.renderProduction({
|
|
24
24
|
serverUrl,
|
|
25
|
-
widgetFile: this.
|
|
25
|
+
widgetFile: this.lookupDistFile(`src/widgets/${name}.tsx`),
|
|
26
26
|
styleFile: this.lookupDistFile("style.css"),
|
|
27
27
|
})
|
|
28
28
|
: templateHelper.renderDevelopment({
|
|
@@ -55,17 +55,8 @@ export class McpServer extends McpServerBase {
|
|
|
55
55
|
return this;
|
|
56
56
|
}
|
|
57
57
|
lookupDistFile(key) {
|
|
58
|
-
const manifest =
|
|
58
|
+
const manifest = JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
59
59
|
return manifest[key]?.file;
|
|
60
60
|
}
|
|
61
|
-
lookupDistBarrelFile(basePath) {
|
|
62
|
-
const manifest = this.readManifest();
|
|
63
|
-
const flatFileKey = `${basePath}.tsx`;
|
|
64
|
-
const barrelFileKey = `${basePath}/index.tsx`;
|
|
65
|
-
return manifest[flatFileKey]?.file ?? manifest[barrelFileKey]?.file;
|
|
66
|
-
}
|
|
67
|
-
readManifest() {
|
|
68
|
-
return JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
69
|
-
}
|
|
70
61
|
}
|
|
71
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,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,UAAU,CAA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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.test.js","sourceRoot":"","sources":["../../../src/test/widget.test.ts"],"names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,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.df1e499",
|
|
4
4
|
"description": "Skybridge is a framework for building ChatGPT apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -23,10 +23,7 @@
|
|
|
23
23
|
"test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
|
|
24
24
|
"test:unit": "vitest run",
|
|
25
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"
|
|
26
|
+
"test:format": "biome ci"
|
|
30
27
|
},
|
|
31
28
|
"keywords": [
|
|
32
29
|
"chatgpt",
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Alpic
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
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>
|