skybridge 0.0.0-dev.96cc308 → 0.0.0-dev.a591879
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/LICENSE +21 -674
- package/dist/src/server/devtoolsStaticServer.d.ts +15 -0
- package/dist/src/server/devtoolsStaticServer.js +43 -0
- package/dist/src/server/devtoolsStaticServer.js.map +1 -0
- package/dist/src/server/index.d.ts +3 -0
- package/dist/src/server/index.js +1 -0
- package/dist/src/server/index.js.map +1 -1
- package/dist/src/server/inferUtilityTypes.d.ts +64 -0
- package/dist/src/server/inferUtilityTypes.js +2 -0
- package/dist/src/server/inferUtilityTypes.js.map +1 -0
- package/dist/src/server/server.d.ts +58 -9
- package/dist/src/server/server.js +13 -5
- package/dist/src/server/server.js.map +1 -1
- package/dist/src/server/templateHelper.js +5 -4
- package/dist/src/server/templateHelper.js.map +1 -1
- package/dist/src/server/templates/development.hbs +1 -1
- package/dist/src/server/widgetsDevServer.js +3 -3
- package/dist/src/server/widgetsDevServer.js.map +1 -1
- package/dist/src/test/utils.d.ts +97 -1
- package/dist/src/test/utils.js +182 -3
- package/dist/src/test/utils.js.map +1 -1
- package/dist/src/test/widget.test.js +26 -21
- package/dist/src/test/widget.test.js.map +1 -1
- package/dist/src/web/create-store.d.ts +3 -0
- package/dist/src/web/create-store.js +25 -0
- package/dist/src/web/create-store.js.map +1 -0
- package/dist/src/web/create-store.test.d.ts +1 -0
- package/dist/src/web/create-store.test.js +70 -0
- package/dist/src/web/create-store.test.js.map +1 -0
- package/dist/src/web/data-llm.d.ts +14 -0
- package/dist/src/web/data-llm.js +68 -0
- package/dist/src/web/data-llm.js.map +1 -0
- package/dist/src/web/data-llm.test.d.ts +1 -0
- package/dist/src/web/data-llm.test.js +76 -0
- package/dist/src/web/data-llm.test.js.map +1 -0
- package/dist/src/web/generate-helpers.d.ts +115 -0
- package/dist/src/web/generate-helpers.js +111 -0
- package/dist/src/web/generate-helpers.js.map +1 -0
- package/dist/src/web/generate-helpers.test-d.d.ts +1 -0
- package/dist/src/web/generate-helpers.test-d.js +180 -0
- package/dist/src/web/generate-helpers.test-d.js.map +1 -0
- package/dist/src/web/generate-helpers.test.d.ts +1 -0
- package/dist/src/web/generate-helpers.test.js +17 -0
- package/dist/src/web/generate-helpers.test.js.map +1 -0
- package/dist/src/web/helpers/state.d.ts +7 -0
- package/dist/src/web/helpers/state.js +40 -0
- package/dist/src/web/helpers/state.js.map +1 -0
- package/dist/src/web/helpers/state.test.d.ts +1 -0
- package/dist/src/web/helpers/state.test.js +53 -0
- package/dist/src/web/helpers/state.test.js.map +1 -0
- package/dist/src/web/hooks/index.d.ts +2 -3
- package/dist/src/web/hooks/index.js +2 -3
- package/dist/src/web/hooks/index.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.d.ts +69 -23
- package/dist/src/web/hooks/use-call-tool.js +26 -10
- package/dist/src/web/hooks/use-call-tool.js.map +1 -1
- package/dist/src/web/hooks/use-call-tool.test-d.d.ts +1 -0
- package/dist/src/web/hooks/use-call-tool.test-d.js +104 -0
- package/dist/src/web/hooks/use-call-tool.test-d.js.map +1 -0
- package/dist/src/web/hooks/use-call-tool.test.js +102 -3
- package/dist/src/web/hooks/use-call-tool.test.js.map +1 -1
- package/dist/src/web/hooks/use-display-mode.js.map +1 -1
- package/dist/src/web/hooks/use-display-mode.test.js +2 -2
- package/dist/src/web/hooks/use-display-mode.test.js.map +1 -1
- package/dist/src/web/hooks/use-files.d.ts +10 -0
- package/dist/src/web/hooks/use-files.js +7 -0
- package/dist/src/web/hooks/use-files.js.map +1 -0
- package/dist/src/web/hooks/use-files.test.d.ts +1 -0
- package/dist/src/web/hooks/use-files.test.js +29 -0
- package/dist/src/web/hooks/use-files.test.js.map +1 -0
- package/dist/src/web/hooks/use-locale.js.map +1 -1
- package/dist/src/web/hooks/use-locale.test.js +2 -2
- package/dist/src/web/hooks/use-locale.test.js.map +1 -1
- package/dist/src/web/hooks/use-open-external.test.js +2 -2
- package/dist/src/web/hooks/use-open-external.test.js.map +1 -1
- package/dist/src/web/hooks/use-openai-global.d.ts +2 -2
- package/dist/src/web/hooks/use-openai-global.js +7 -5
- package/dist/src/web/hooks/use-openai-global.js.map +1 -1
- package/dist/src/web/hooks/use-request-modal.d.ts +3 -2
- package/dist/src/web/hooks/use-request-modal.js.map +1 -1
- package/dist/src/web/hooks/use-request-modal.test.js +2 -2
- package/dist/src/web/hooks/use-request-modal.test.js.map +1 -1
- package/dist/src/web/hooks/use-theme.js.map +1 -1
- package/dist/src/web/hooks/use-theme.test.js +2 -2
- package/dist/src/web/hooks/use-theme.test.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.d.ts +18 -11
- package/dist/src/web/hooks/use-tool-info.js +4 -6
- package/dist/src/web/hooks/use-tool-info.js.map +1 -1
- package/dist/src/web/hooks/use-tool-info.test-d.d.ts +1 -0
- package/dist/src/web/hooks/use-tool-info.test-d.js +73 -0
- package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -0
- package/dist/src/web/hooks/use-tool-info.test.js +2 -2
- package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
- package/dist/src/web/hooks/use-user-agent.js.map +1 -1
- package/dist/src/web/hooks/use-user-agent.test.js +2 -2
- package/dist/src/web/hooks/use-user-agent.test.js.map +1 -1
- package/dist/src/web/hooks/use-widget-state.js +9 -7
- package/dist/src/web/hooks/use-widget-state.js.map +1 -1
- package/dist/src/web/hooks/use-widget-state.test.js +2 -2
- package/dist/src/web/hooks/use-widget-state.test.js.map +1 -1
- package/dist/src/web/index.d.ts +6 -3
- package/dist/src/web/index.js +6 -3
- package/dist/src/web/index.js.map +1 -1
- package/dist/src/web/mount-widget.js +5 -0
- package/dist/src/web/mount-widget.js.map +1 -1
- package/dist/src/web/plugin/data-llm.test.d.ts +1 -0
- package/dist/src/web/plugin/data-llm.test.js +81 -0
- package/dist/src/web/plugin/data-llm.test.js.map +1 -0
- package/dist/src/web/{plugin.js → plugin/plugin.js} +5 -0
- package/dist/src/web/plugin/plugin.js.map +1 -0
- package/dist/src/web/plugin/transform-data-llm.d.ts +12 -0
- package/dist/src/web/plugin/transform-data-llm.js +93 -0
- package/dist/src/web/plugin/transform-data-llm.js.map +1 -0
- package/dist/src/web/plugin/transform-data-llm.test.d.ts +1 -0
- package/dist/src/web/plugin/transform-data-llm.test.js +81 -0
- package/dist/src/web/plugin/transform-data-llm.test.js.map +1 -0
- package/dist/src/web/proxy.d.ts +1 -0
- package/dist/src/web/proxy.js +48 -0
- package/dist/src/web/proxy.js.map +1 -0
- package/dist/src/web/types.d.ts +42 -20
- package/dist/src/web/types.js +1 -0
- package/dist/src/web/types.js.map +1 -1
- package/package.json +20 -16
- package/README.md +0 -198
- package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
- package/dist/src/web/hooks/use-tool-output.js +0 -9
- package/dist/src/web/hooks/use-tool-output.js.map +0 -1
- package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
- package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
- package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
- package/dist/src/web/plugin.js.map +0 -1
- /package/dist/src/web/{plugin.d.ts → plugin/plugin.d.ts} +0 -0
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
const colors = {
|
|
2
|
+
brand: "#6366f1",
|
|
3
|
+
info: "#22223b",
|
|
4
|
+
success: "#22c55e",
|
|
5
|
+
error: "#ef4444",
|
|
6
|
+
};
|
|
7
|
+
export function installOpenAILoggingProxy() {
|
|
8
|
+
if (typeof window === "undefined" || !window.openai) {
|
|
9
|
+
console.warn("[openai-proxy] window.openai not found, skipping proxy installation");
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
const originalOpenAI = window.openai;
|
|
13
|
+
const handler = {
|
|
14
|
+
get(target, prop, receiver) {
|
|
15
|
+
const value = Reflect.get(target, prop, receiver);
|
|
16
|
+
if (typeof value !== "function") {
|
|
17
|
+
return value;
|
|
18
|
+
}
|
|
19
|
+
return (...args) => {
|
|
20
|
+
const methodName = String(prop);
|
|
21
|
+
console.group(`%c[openai] %cmethod %c${methodName}`, `color: ${colors.brand}; font-weight: normal`, `color: ${colors.info}; font-weight: normal`, `color: ${colors.success}`);
|
|
22
|
+
console.log("%c← args:", `color: ${colors.info}`, args);
|
|
23
|
+
const result = value.apply(target, args);
|
|
24
|
+
if (result && typeof result.then === "function") {
|
|
25
|
+
return result.then((resolved) => {
|
|
26
|
+
console.log("%c→ resolved:", `color: ${colors.success}`, resolved);
|
|
27
|
+
console.groupEnd();
|
|
28
|
+
return resolved;
|
|
29
|
+
}, (error) => {
|
|
30
|
+
console.error("%c→ rejected:", `color: ${colors.error}`, error);
|
|
31
|
+
console.groupEnd();
|
|
32
|
+
throw error;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
console.log("%c→ returned:", `color: ${colors.success}`, result);
|
|
36
|
+
console.groupEnd();
|
|
37
|
+
return result;
|
|
38
|
+
};
|
|
39
|
+
},
|
|
40
|
+
set(target, prop, value, receiver) {
|
|
41
|
+
console.log(`%c[openai] %cupdate %c${String(prop)}`, `color: ${colors.brand}`, `color: ${colors.info}`, `color: ${colors.success}; font-weight: bold`, "←", value);
|
|
42
|
+
return Reflect.set(target, prop, value, receiver);
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
window.openai = new Proxy(originalOpenAI, handler);
|
|
46
|
+
console.log("%c[openai-proxy] %cInstalled logging proxy for window.openai", `color: ${colors.brand}`, `color: ${colors.info}`);
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=proxy.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../src/web/proxy.ts"],"names":[],"mappings":"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"}
|
package/dist/src/web/types.d.ts
CHANGED
|
@@ -1,17 +1,21 @@
|
|
|
1
|
+
import "react";
|
|
2
|
+
declare module "react" {
|
|
3
|
+
interface HTMLAttributes<T> {
|
|
4
|
+
"data-llm"?: string;
|
|
5
|
+
}
|
|
6
|
+
}
|
|
1
7
|
export type UnknownObject = Record<string, unknown>;
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export type RequestModalOptions = {
|
|
14
|
-
title: string;
|
|
8
|
+
export type Prettify<T> = {
|
|
9
|
+
[K in keyof T]: T[K];
|
|
10
|
+
} & {};
|
|
11
|
+
export type Objectify<T> = T & UnknownObject;
|
|
12
|
+
type RequiredKeys<T> = {
|
|
13
|
+
[K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
|
|
14
|
+
}[keyof T];
|
|
15
|
+
export type HasRequiredKeys<T> = RequiredKeys<T> extends never ? false : true;
|
|
16
|
+
type WidgetState = UnknownObject;
|
|
17
|
+
type FileMetadata = {
|
|
18
|
+
fileId: string;
|
|
15
19
|
};
|
|
16
20
|
export declare const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
|
|
17
21
|
export declare class ToolResponseEvent extends CustomEvent<{
|
|
@@ -24,13 +28,13 @@ export declare class ToolResponseEvent extends CustomEvent<{
|
|
|
24
28
|
}
|
|
25
29
|
declare global {
|
|
26
30
|
interface Window {
|
|
27
|
-
openai:
|
|
31
|
+
openai: OpenAiMethods<WidgetState> & OpenAiProperties;
|
|
28
32
|
}
|
|
29
33
|
interface WindowEventMap {
|
|
30
34
|
[SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
|
|
31
35
|
}
|
|
32
36
|
}
|
|
33
|
-
export type
|
|
37
|
+
export type OpenAiProperties<ToolInput extends UnknownObject = Record<never, unknown>, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
|
|
34
38
|
theme: Theme;
|
|
35
39
|
userAgent: UserAgent;
|
|
36
40
|
locale: string;
|
|
@@ -43,8 +47,6 @@ export type OpenAiGlobals<ToolInput extends UnknownObject = {}, ToolOutput exten
|
|
|
43
47
|
} | null;
|
|
44
48
|
toolResponseMetadata: ToolResponseMetadata | null;
|
|
45
49
|
widgetState: WidgetState | null;
|
|
46
|
-
requestDisplayMode: RequestDisplayMode;
|
|
47
|
-
requestModal: RequestModal;
|
|
48
50
|
};
|
|
49
51
|
export type CallToolArgs = Record<string, unknown> | null;
|
|
50
52
|
export type CallToolResponse = {
|
|
@@ -57,7 +59,7 @@ export type CallToolResponse = {
|
|
|
57
59
|
result: string;
|
|
58
60
|
meta: Record<string, unknown>;
|
|
59
61
|
};
|
|
60
|
-
type
|
|
62
|
+
export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
|
|
61
63
|
/** Calls a tool on your MCP. Returns the full response. */
|
|
62
64
|
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
63
65
|
/** Triggers a followup turn in the ChatGPT conversation */
|
|
@@ -65,7 +67,7 @@ type API<WidgetState extends UnknownObject> = {
|
|
|
65
67
|
prompt: string;
|
|
66
68
|
}) => Promise<void>;
|
|
67
69
|
/** Opens an external link, redirects web page or mobile app */
|
|
68
|
-
openExternal(
|
|
70
|
+
openExternal(args: {
|
|
69
71
|
href: string;
|
|
70
72
|
}): void;
|
|
71
73
|
/** For transitioning an app from inline to fullscreen or pip */
|
|
@@ -78,11 +80,31 @@ type API<WidgetState extends UnknownObject> = {
|
|
|
78
80
|
*/
|
|
79
81
|
mode: DisplayMode;
|
|
80
82
|
}>;
|
|
83
|
+
/**
|
|
84
|
+
* Sets the widget state.
|
|
85
|
+
* This state is persisted across widget renders.
|
|
86
|
+
*/
|
|
81
87
|
setWidgetState: (state: WidgetState) => Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* Opens a modal portaled outside of the widget iFrame.
|
|
90
|
+
* This ensures the modal is correctly displayed and not limited to the widget's area.
|
|
91
|
+
*/
|
|
92
|
+
requestModal: (args: {
|
|
93
|
+
title: string;
|
|
94
|
+
}) => Promise<void>;
|
|
95
|
+
/** Uploads a new file to the host */
|
|
96
|
+
uploadFile: (file: File) => Promise<FileMetadata>;
|
|
97
|
+
/**
|
|
98
|
+
* Downloads a file from the host that was previously uploaded.
|
|
99
|
+
* Only files uploaded by the same connector instance can be downloaded.
|
|
100
|
+
*/
|
|
101
|
+
downloadFile: (file: FileMetadata) => Promise<{
|
|
102
|
+
downloadUrl: string;
|
|
103
|
+
}>;
|
|
82
104
|
};
|
|
83
105
|
export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
84
106
|
export declare class SetGlobalsEvent extends CustomEvent<{
|
|
85
|
-
globals: Partial<
|
|
107
|
+
globals: Partial<OpenAiProperties>;
|
|
86
108
|
}> {
|
|
87
109
|
readonly type = "openai:set_globals";
|
|
88
110
|
}
|
package/dist/src/web/types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,CAAC;AAuBf,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AA8FD,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,MAAM,OAAO,eAAgB,SAAQ,WAEnC;IACkB,IAAI,GAAG,sBAAsB,CAAC;CACjD"}
|
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.a591879",
|
|
4
4
|
"description": "Skybridge is a framework for building ChatGPT apps",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"files": [
|
|
@@ -16,16 +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
|
-
"test": "pnpm run test:unit && pnpm run test:type",
|
|
23
|
-
"test:unit": "vitest run --silent",
|
|
24
|
-
"test:type": "tsc --noEmit",
|
|
25
|
-
"docs:dev": "pnpm --filter @skybridge/docs start",
|
|
26
|
-
"docs:build": "pnpm --filter @skybridge/docs build",
|
|
27
|
-
"docs:serve": "pnpm --filter @skybridge/docs serve"
|
|
28
|
-
},
|
|
29
19
|
"keywords": [
|
|
30
20
|
"chatgpt",
|
|
31
21
|
"app",
|
|
@@ -35,21 +25,26 @@
|
|
|
35
25
|
"author": "Frédéric Barthelet",
|
|
36
26
|
"license": "ISC",
|
|
37
27
|
"peerDependencies": {
|
|
28
|
+
"@modelcontextprotocol/sdk": ">=1.0.0",
|
|
38
29
|
"react": ">=18.0.0",
|
|
39
30
|
"react-dom": ">=18.0.0"
|
|
40
31
|
},
|
|
41
32
|
"dependencies": {
|
|
42
|
-
"@
|
|
33
|
+
"@babel/core": "^7.28.5",
|
|
43
34
|
"cors": "^2.8.5",
|
|
44
35
|
"express": "^5.1.0",
|
|
45
36
|
"handlebars": "^4.7.8",
|
|
37
|
+
"superjson": "^2.2.6",
|
|
46
38
|
"vite": "^7.1.11",
|
|
47
|
-
"
|
|
39
|
+
"zustand": "^5.0.9"
|
|
48
40
|
},
|
|
49
41
|
"devDependencies": {
|
|
42
|
+
"@biomejs/biome": "2.3.8",
|
|
43
|
+
"@modelcontextprotocol/sdk": "^1.24.3",
|
|
50
44
|
"@testing-library/dom": "^10.4.1",
|
|
51
45
|
"@testing-library/react": "^16.3.0",
|
|
52
46
|
"@total-typescript/tsconfig": "^1.0.4",
|
|
47
|
+
"@types/babel__core": "^7.20.5",
|
|
53
48
|
"@types/cors": "^2.8.19",
|
|
54
49
|
"@types/express": "^5.0.3",
|
|
55
50
|
"@types/jsdom": "^21.1.6",
|
|
@@ -59,7 +54,16 @@
|
|
|
59
54
|
"@vitest/ui": "^2.1.8",
|
|
60
55
|
"jsdom": "^25.0.1",
|
|
61
56
|
"typescript": "^5.9.3",
|
|
62
|
-
"vitest": "^2.1.8"
|
|
57
|
+
"vitest": "^2.1.8",
|
|
58
|
+
"zod": "^4.1.13"
|
|
63
59
|
},
|
|
64
|
-
"
|
|
65
|
-
|
|
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,198 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
# Skybridge
|
|
4
|
-
|
|
5
|
-
**Skybridge is the TypeScript framework for building ChatGPT apps**
|
|
6
|
-
|
|
7
|
-
[](https://alpic.ai)
|
|
8
|
-
|
|
9
|
-

|
|
10
|
-

|
|
11
|
-

|
|
12
|
-
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
Skybridge comes with 2 packages:
|
|
16
|
-
|
|
17
|
-
- `skybridge/server`: A drop-in replacement of the `@modelcontextprotocol/sdk` official `McpServer` class with extra features for widget development.
|
|
18
|
-
- `skybridge/web`: A react library with hooks and components to build widgets on the underlying _OpenAI iFrame skybridge_ runtime.
|
|
19
|
-
|
|
20
|
-
## Quick start
|
|
21
|
-
|
|
22
|
-
To get started in less than a minute, you can [create a new repository](https://github.com/new?template_name=apps-sdk-template&template_owner=alpic-ai) using our [ChatGPT SDK template](https://github.com/alpic-ai/apps-sdk-template). This template includes a basic setup for both the server and the widgets.
|
|
23
|
-
|
|
24
|
-
## Installation
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
pnpm add skybridge
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Concepts
|
|
31
|
-
|
|
32
|
-
### Widgets
|
|
33
|
-
|
|
34
|
-
> A widget is a UI component that turns structured tool results into a human-friendly UI. Those are built using React components. They are rendered inside an iframe inline with the conversation on ChatGPT.
|
|
35
|
-
|
|
36
|
-
Each widget in your app must have a unique name. The name is used to bridge the tool invocation result with the widget React component.
|
|
37
|
-
|
|
38
|
-
For example, in order to register a new widget named `pokemon` on your ChatGPT app. You should have the following file structure and file contents:
|
|
39
|
-
|
|
40
|
-
_Project structure_
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
server/
|
|
44
|
-
└── src/
|
|
45
|
-
└── index.ts // Register the widget with McpServer.widget()
|
|
46
|
-
web/
|
|
47
|
-
└── src/
|
|
48
|
-
└── widgets/
|
|
49
|
-
└── pokemon.tsx // Use the same widget name as the file name
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
_server/src/index.ts_
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
import { McpServer } from "skybridge/server";
|
|
56
|
-
|
|
57
|
-
const server = new McpServer();
|
|
58
|
-
|
|
59
|
-
server.widget(
|
|
60
|
-
"pokemon"
|
|
61
|
-
// Remaining arguments...
|
|
62
|
-
);
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
_web/src/widgets/pokemon.tsx_
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
import { mountWidget } from "skybridge/web";
|
|
69
|
-
|
|
70
|
-
const Pokemon: React.FunctionComponent = () => {
|
|
71
|
-
// Your React component code goes here...
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
mountWidget(<Pokemon />);
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Packages
|
|
78
|
-
|
|
79
|
-
### skybridge/server
|
|
80
|
-
|
|
81
|
-
The `skybridge/server` package is a drop-in replacement of the `@modelcontextprotocol/sdk` official `McpServer` class with extra features for widget development. If you're already using the `@modelcontextprotocol/sdk`, you can simply replace your `McpServer` import with `skybridge/server` and you're good to go.
|
|
82
|
-
|
|
83
|
-
### skybridge/web
|
|
84
|
-
|
|
85
|
-
The `skybridge/web` package is a react library with hooks and components to build widgets on the underlying _OpenAI iFrame skybridge_ runtime.
|
|
86
|
-
|
|
87
|
-
**Vite plugin**
|
|
88
|
-
|
|
89
|
-
The `skybridge/web` package comes with a Vite plugin that allows you to build your widgets as regular Vite apps.
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
import { defineConfig } from "vite";
|
|
93
|
-
import { skybridge } from "skybridge/web";
|
|
94
|
-
|
|
95
|
-
export default defineConfig({
|
|
96
|
-
plugins: [skybridge()],
|
|
97
|
-
});
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**Hooks**
|
|
101
|
-
|
|
102
|
-
The `skybridge/web` package comes with a set of hooks to help you build your widgets :
|
|
103
|
-
|
|
104
|
-
- `useOpenAiGlobal`: A generic hook to get any global data from the OpenAI iFrame skybridge runtime (in `window.openai`).
|
|
105
|
-
- `useToolOutput`: A hook to get the initial tool `structuredContent` returned when rendering the widget for the first time. The data inside this hook is not updated when the tool is called again.
|
|
106
|
-
- `useToolResponseMetadata`: A hook to get the initial tool `meta` returned when rendering the widget for the first time. The data inside this hook is not updated when the tool is called again.
|
|
107
|
-
- `useCallTool`: A @tanstack/react-query inspired hook to send make additional tool calls inside a widget.
|
|
108
|
-
|
|
109
|
-
_useOpenAiGlobal_
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
import { useOpenAiGlobal } from "skybridge/web";
|
|
113
|
-
|
|
114
|
-
const theme = useOpenAiGlobal("theme");
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
_useToolOutput_
|
|
118
|
-
|
|
119
|
-
```ts
|
|
120
|
-
import { useToolOutput } from "skybridge/web";
|
|
121
|
-
|
|
122
|
-
const toolOutput = useToolOutput();
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
_useToolResponseMetadata_
|
|
126
|
-
|
|
127
|
-
```ts
|
|
128
|
-
import { useToolResponseMetadata } from "skybridge/web";
|
|
129
|
-
|
|
130
|
-
const toolResponseMetadata = useToolResponseMetadata();
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
_useCallTool_ in synchronous mode
|
|
134
|
-
|
|
135
|
-
```ts
|
|
136
|
-
import { useCallTool } from "skybridge/web";
|
|
137
|
-
|
|
138
|
-
export const TestTool: React.FunctionComponent = () => {
|
|
139
|
-
const { callTool, isPending } = useCallTool("myToolName");
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<div>
|
|
143
|
-
<button
|
|
144
|
-
disabled={isPending}
|
|
145
|
-
onClick={() => {
|
|
146
|
-
callTool({ input: "test input" }, {
|
|
147
|
-
onSuccess: (data) => {
|
|
148
|
-
alert("Tool returned: " + data);
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
>
|
|
152
|
-
Call Tool inside a widget
|
|
153
|
-
</button>
|
|
154
|
-
</div>
|
|
155
|
-
);
|
|
156
|
-
};
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
_useCallTool_ in asynchronous mode
|
|
160
|
-
|
|
161
|
-
```ts
|
|
162
|
-
import { useCallTool } from "skybridge/web";
|
|
163
|
-
|
|
164
|
-
export const TestTool: React.FunctionComponent = () => {
|
|
165
|
-
const { callToolAsync, isPending } = useCallTool("myToolName");
|
|
166
|
-
|
|
167
|
-
return (
|
|
168
|
-
<div>
|
|
169
|
-
<button
|
|
170
|
-
disabled={isPending}
|
|
171
|
-
onClick={async () => {
|
|
172
|
-
const data = await callToolAsync({ input: "test input" });
|
|
173
|
-
alert("Tool returned: " + data);
|
|
174
|
-
}}
|
|
175
|
-
>
|
|
176
|
-
Call Tool inside a widget
|
|
177
|
-
</button>
|
|
178
|
-
</div>
|
|
179
|
-
);
|
|
180
|
-
};
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
## Migrate your existing MCP server to a ChatGPT app
|
|
184
|
-
|
|
185
|
-
If you're already using the `@modelcontextprotocol/sdk` to build a MCP server, you can migrate to a ChatGPT app by following these steps:
|
|
186
|
-
|
|
187
|
-
1. Replace your `McpServer` import from `@modelcontextprotocol/sdk` with the same import from `skybridge/server`
|
|
188
|
-
2. Create a new vite project in a folder named `web` and install the `skybridge` package
|
|
189
|
-
3. Replace the `vite.config.ts` file with the following:
|
|
190
|
-
|
|
191
|
-
```ts
|
|
192
|
-
import { defineConfig } from "vite";
|
|
193
|
-
import { skybridge } from "skybridge/web";
|
|
194
|
-
|
|
195
|
-
export default defineConfig({
|
|
196
|
-
plugins: [skybridge()],
|
|
197
|
-
});
|
|
198
|
-
```
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { useToolInfo } from "./use-tool-info.js";
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated This hook is deprecated. Use `useToolInfo()` instead and access the `output` property.
|
|
4
|
-
*/
|
|
5
|
-
export function useToolOutput() {
|
|
6
|
-
const { output } = useToolInfo();
|
|
7
|
-
return output;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=use-tool-output.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-tool-output.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-tool-output.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEjD;;GAEG;AACH,MAAM,UAAU,aAAa;IAC3B,MAAM,EAAE,MAAM,EAAE,GAAG,WAAW,EAAE,CAAC;IAEjC,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { useOpenAiGlobal } from "./use-openai-global.js";
|
|
2
|
-
/**
|
|
3
|
-
* @deprecated This hook is deprecated. Use `useToolInfo()` instead and access the `responseMetadata` property.
|
|
4
|
-
*/
|
|
5
|
-
export function useToolResponseMetadata() {
|
|
6
|
-
return useOpenAiGlobal("toolResponseMetadata");
|
|
7
|
-
}
|
|
8
|
-
//# sourceMappingURL=use-tool-response-metadata.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"use-tool-response-metadata.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-tool-response-metadata.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAEzD;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,eAAe,CAAC,sBAAsB,CAAC,CAAC;AACjD,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","sourceRoot":"","sources":["../../../src/web/plugin.ts"],"names":[],"mappings":"AAEA,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;KACF,CAAC;AACJ,CAAC"}
|
|
File without changes
|