skybridge 0.0.0-dev.7ca051e → 0.0.0-dev.828269f

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 (99) hide show
  1. package/LICENSE +21 -674
  2. package/dist/src/server/devtoolsStaticServer.d.ts +15 -0
  3. package/dist/src/server/devtoolsStaticServer.js +43 -0
  4. package/dist/src/server/devtoolsStaticServer.js.map +1 -0
  5. package/dist/src/server/index.d.ts +3 -2
  6. package/dist/src/server/index.js +1 -0
  7. package/dist/src/server/index.js.map +1 -1
  8. package/dist/src/server/inferUtilityTypes.d.ts +10 -0
  9. package/dist/src/server/server.d.ts +30 -16
  10. package/dist/src/server/server.js +4 -4
  11. package/dist/src/server/server.js.map +1 -1
  12. package/dist/src/server/templateHelper.js +5 -4
  13. package/dist/src/server/templateHelper.js.map +1 -1
  14. package/dist/src/server/templates/development.hbs +1 -1
  15. package/dist/src/server/widgetsDevServer.js +3 -3
  16. package/dist/src/server/widgetsDevServer.js.map +1 -1
  17. package/dist/src/test/utils.d.ts +44 -9
  18. package/dist/src/test/utils.js +66 -8
  19. package/dist/src/test/utils.js.map +1 -1
  20. package/dist/src/test/widget.test.js +26 -21
  21. package/dist/src/test/widget.test.js.map +1 -1
  22. package/dist/src/web/create-store.d.ts +3 -0
  23. package/dist/src/web/create-store.js +25 -0
  24. package/dist/src/web/create-store.js.map +1 -0
  25. package/dist/src/web/create-store.test.d.ts +1 -0
  26. package/dist/src/web/create-store.test.js +70 -0
  27. package/dist/src/web/create-store.test.js.map +1 -0
  28. package/dist/src/web/data-llm.d.ts +1 -0
  29. package/dist/src/web/data-llm.js +4 -3
  30. package/dist/src/web/data-llm.js.map +1 -1
  31. package/dist/src/web/data-llm.test.js.map +1 -1
  32. package/dist/src/web/generate-helpers.d.ts +11 -11
  33. package/dist/src/web/generate-helpers.js +6 -4
  34. package/dist/src/web/generate-helpers.js.map +1 -1
  35. package/dist/src/web/generate-helpers.test-d.js +32 -3
  36. package/dist/src/web/generate-helpers.test-d.js.map +1 -1
  37. package/dist/src/web/generate-helpers.test.js +1 -1
  38. package/dist/src/web/generate-helpers.test.js.map +1 -1
  39. package/dist/src/web/helpers/state.d.ts +7 -0
  40. package/dist/src/web/helpers/state.js +40 -0
  41. package/dist/src/web/helpers/state.js.map +1 -0
  42. package/dist/src/web/helpers/state.test.d.ts +1 -0
  43. package/dist/src/web/helpers/state.test.js +53 -0
  44. package/dist/src/web/helpers/state.test.js.map +1 -0
  45. package/dist/src/web/hooks/index.d.ts +2 -4
  46. package/dist/src/web/hooks/index.js +1 -3
  47. package/dist/src/web/hooks/index.js.map +1 -1
  48. package/dist/src/web/hooks/use-call-tool.d.ts +1 -1
  49. package/dist/src/web/hooks/use-call-tool.js.map +1 -1
  50. package/dist/src/web/hooks/use-call-tool.test-d.js +1 -1
  51. package/dist/src/web/hooks/use-call-tool.test-d.js.map +1 -1
  52. package/dist/src/web/hooks/use-call-tool.test.js +9 -15
  53. package/dist/src/web/hooks/use-call-tool.test.js.map +1 -1
  54. package/dist/src/web/hooks/use-display-mode.js.map +1 -1
  55. package/dist/src/web/hooks/use-display-mode.test.js +2 -2
  56. package/dist/src/web/hooks/use-display-mode.test.js.map +1 -1
  57. package/dist/src/web/hooks/use-files.test.js +1 -1
  58. package/dist/src/web/hooks/use-files.test.js.map +1 -1
  59. package/dist/src/web/hooks/use-locale.js.map +1 -1
  60. package/dist/src/web/hooks/use-locale.test.js +2 -2
  61. package/dist/src/web/hooks/use-locale.test.js.map +1 -1
  62. package/dist/src/web/hooks/use-open-external.test.js +2 -2
  63. package/dist/src/web/hooks/use-open-external.test.js.map +1 -1
  64. package/dist/src/web/hooks/use-openai-global.d.ts +2 -2
  65. package/dist/src/web/hooks/use-openai-global.js +7 -5
  66. package/dist/src/web/hooks/use-openai-global.js.map +1 -1
  67. package/dist/src/web/hooks/use-request-modal.test.js +2 -2
  68. package/dist/src/web/hooks/use-request-modal.test.js.map +1 -1
  69. package/dist/src/web/hooks/use-theme.js.map +1 -1
  70. package/dist/src/web/hooks/use-theme.test.js +2 -2
  71. package/dist/src/web/hooks/use-theme.test.js.map +1 -1
  72. package/dist/src/web/hooks/use-tool-info.d.ts +1 -1
  73. package/dist/src/web/hooks/use-tool-info.js +4 -6
  74. package/dist/src/web/hooks/use-tool-info.js.map +1 -1
  75. package/dist/src/web/hooks/use-tool-info.test-d.js +0 -1
  76. package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -1
  77. package/dist/src/web/hooks/use-tool-info.test.js +2 -2
  78. package/dist/src/web/hooks/use-tool-info.test.js.map +1 -1
  79. package/dist/src/web/hooks/use-user-agent.js.map +1 -1
  80. package/dist/src/web/hooks/use-user-agent.test.js +2 -2
  81. package/dist/src/web/hooks/use-user-agent.test.js.map +1 -1
  82. package/dist/src/web/hooks/use-widget-state.js +3 -25
  83. package/dist/src/web/hooks/use-widget-state.js.map +1 -1
  84. package/dist/src/web/hooks/use-widget-state.test.js +2 -2
  85. package/dist/src/web/hooks/use-widget-state.test.js.map +1 -1
  86. package/dist/src/web/index.d.ts +4 -3
  87. package/dist/src/web/index.js +4 -3
  88. package/dist/src/web/index.js.map +1 -1
  89. package/dist/src/web/proxy.js +1 -1
  90. package/dist/src/web/proxy.js.map +1 -1
  91. package/dist/src/web/types.d.ts +6 -6
  92. package/package.json +18 -16
  93. package/README.md +0 -371
  94. package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
  95. package/dist/src/web/hooks/use-tool-output.js +0 -9
  96. package/dist/src/web/hooks/use-tool-output.js.map +0 -1
  97. package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
  98. package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
  99. package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"use-widget-state.test.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-widget-state.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,uBAA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C,CAAC,CAAC;QAE5E,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,YAAY,CAAC,CAAC;QAEhD,8CAA8C;QAC9C,UAAU,CAAC,WAAW,GAAG,WAAW,CAAC;QACrC,sDAAsD;QACtD,QAAQ,EAAE,CAAC;QAEX,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC;IACjD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -1,6 +1,7 @@
1
- export * from "./types.js";
1
+ export { createStore } from "./create-store.js";
2
2
  export * from "./data-llm.js";
3
+ export { generateHelpers } from "./generate-helpers.js";
4
+ export * from "./hooks/index.js";
3
5
  export { mountWidget } from "./mount-widget.js";
4
6
  export { skybridge } from "./plugin/plugin.js";
5
- export * from "./hooks/index.js";
6
- export { generateHelpers } from "./generate-helpers.js";
7
+ export * from "./types.js";
@@ -1,7 +1,8 @@
1
- export * from "./types.js";
1
+ export { createStore } from "./create-store.js";
2
2
  export * from "./data-llm.js";
3
+ export { generateHelpers } from "./generate-helpers.js";
4
+ export * from "./hooks/index.js";
3
5
  export { mountWidget } from "./mount-widget.js";
4
6
  export { skybridge } from "./plugin/plugin.js";
5
- export * from "./hooks/index.js";
6
- export { generateHelpers } from "./generate-helpers.js";
7
+ export * from "./types.js";
7
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC;AAC3B,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/web/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,cAAc,kBAAkB,CAAC;AACjC,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAC/C,cAAc,YAAY,CAAC"}
@@ -16,7 +16,7 @@ export function installOpenAILoggingProxy() {
16
16
  if (typeof value !== "function") {
17
17
  return value;
18
18
  }
19
- return function (...args) {
19
+ return (...args) => {
20
20
  const methodName = String(prop);
21
21
  console.group(`%c[openai] %cmethod %c${methodName}`, `color: ${colors.brand}; font-weight: normal`, `color: ${colors.info}; font-weight: normal`, `color: ${colors.success}`);
22
22
  console.log("%c← args:", `color: ${colors.info}`, args);
@@ -1 +1 @@
1
- {"version":3,"file":"proxy.js","sourceRoot":"","sources":["../../../src/web/proxy.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,OAAO,EAAE,SAAS;IAClB,KAAK,EAAE,SAAS;CACR,CAAC;AAEX,MAAM,UAAU,yBAAyB;IACvC,IAAI,OAAO,MAAM,KAAK,WAAW,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QACpD,OAAO,CAAC,IAAI,CACV,qEAAqE,CACtE,CAAC;QACF,OAAO;IACT,CAAC;IAED,MAAM,cAAc,GAAG,MAAM,CAAC,MAAM,CAAC;IAErC,MAAM,OAAO,GAAwC;QACnD,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ;YACxB,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;YAElD,IAAI,OAAO,KAAK,KAAK,U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,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ;YAC/B,OAAO,CAAC,GAAG,CACT,yBAAyB,MAAM,CAAC,IAAI,CAAC,EAAE,EACvC,UAAU,MAAM,CAAC,KAAK,EAAE,EACxB,UAAU,MAAM,CAAC,IAAI,EAAE,EACvB,UAAU,MAAM,CAAC,OAAO,qBAAqB,EAC7C,GAAG,EACH,KAAK,CACN,CAAC;YAEF,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,QAAQ,CAAC,CAAC;QACpD,CAAC;KACF,CAAC;IAEF,MAAM,CAAC,MAAM,GAAG,IAAI,KAAK,CAAC,cAAc,EAAE,OAAO,CAAC,CAAC;IAEnD,OAAO,CAAC,GAAG,CACT,8DAA8D,EAC9D,UAAU,MAAM,CAAC,KAAK,EAAE,EACxB,UAAU,MAAM,CAAC,IAAI,EAAE,CACxB,CAAC;AACJ,CAAC"}
@@ -1,6 +1,6 @@
1
1
  import "react";
2
2
  declare module "react" {
3
- interface HTMLAttributes<T extends Element = HTMLElement> {
3
+ interface HTMLAttributes<T> {
4
4
  "data-llm"?: string;
5
5
  }
6
6
  }
@@ -10,7 +10,7 @@ export type Prettify<T> = {
10
10
  } & {};
11
11
  export type Objectify<T> = T & UnknownObject;
12
12
  type RequiredKeys<T> = {
13
- [K in keyof T]-?: {} extends Pick<T, K> ? never : K;
13
+ [K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
14
14
  }[keyof T];
15
15
  export type HasRequiredKeys<T> = RequiredKeys<T> extends never ? false : true;
16
16
  type WidgetState = UnknownObject;
@@ -28,13 +28,13 @@ export declare class ToolResponseEvent extends CustomEvent<{
28
28
  }
29
29
  declare global {
30
30
  interface Window {
31
- openai: API<WidgetState> & OpenAiGlobals;
31
+ openai: OpenAiMethods<WidgetState> & OpenAiProperties;
32
32
  }
33
33
  interface WindowEventMap {
34
34
  [SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
35
35
  }
36
36
  }
37
- export type OpenAiGlobals<ToolInput extends UnknownObject = {}, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
37
+ export type OpenAiProperties<ToolInput extends UnknownObject = Record<never, unknown>, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
38
38
  theme: Theme;
39
39
  userAgent: UserAgent;
40
40
  locale: string;
@@ -59,7 +59,7 @@ export type CallToolResponse = {
59
59
  result: string;
60
60
  meta: Record<string, unknown>;
61
61
  };
62
- type API<WidgetState extends UnknownObject> = {
62
+ export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
63
63
  /** Calls a tool on your MCP. Returns the full response. */
64
64
  callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
65
65
  /** Triggers a followup turn in the ChatGPT conversation */
@@ -104,7 +104,7 @@ type API<WidgetState extends UnknownObject> = {
104
104
  };
105
105
  export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
106
106
  export declare class SetGlobalsEvent extends CustomEvent<{
107
- globals: Partial<OpenAiGlobals>;
107
+ globals: Partial<OpenAiProperties>;
108
108
  }> {
109
109
  readonly type = "openai:set_globals";
110
110
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "skybridge",
3
- "version": "0.0.0-dev.7ca051e",
3
+ "version": "0.0.0-dev.828269f",
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",
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,19 +25,22 @@
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
- "@modelcontextprotocol/sdk": "^1.20.0",
44
34
  "cors": "^2.8.5",
45
35
  "express": "^5.1.0",
46
36
  "handlebars": "^4.7.8",
37
+ "superjson": "^2.2.6",
47
38
  "vite": "^7.1.11",
48
- "zod": "^3.25.51"
39
+ "zustand": "^5.0.9"
49
40
  },
50
41
  "devDependencies": {
42
+ "@biomejs/biome": "2.3.8",
43
+ "@modelcontextprotocol/sdk": "^1.24.3",
51
44
  "@testing-library/dom": "^10.4.1",
52
45
  "@testing-library/react": "^16.3.0",
53
46
  "@total-typescript/tsconfig": "^1.0.4",
@@ -61,7 +54,16 @@
61
54
  "@vitest/ui": "^2.1.8",
62
55
  "jsdom": "^25.0.1",
63
56
  "typescript": "^5.9.3",
64
- "vitest": "^2.1.8"
57
+ "vitest": "^2.1.8",
58
+ "zod": "^4.1.13"
65
59
  },
66
- "packageManager": "pnpm@10.17.1"
67
- }
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,371 +0,0 @@
1
- <div align="center">
2
-
3
- # Skybridge
4
-
5
- **Skybridge is the TypeScript framework for building ChatGPT apps**
6
-
7
- [![By Alpic](https://img.shields.io/badge/Made%20by%20Alpic-f6ffed?logo=alpic)](https://alpic.ai)
8
-
9
- ![NPM Downloads](https://img.shields.io/npm/dm/skybridge?color=e90060)
10
- ![NPM Version](https://img.shields.io/npm/v/skybridge?color=e90060)
11
- ![GitHub License](https://img.shields.io/github/license/alpic-ai/skybridge?color=e90060)
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
- **Typed Hooks**
101
-
102
- Skybridge provides fully typed hooks that give you autocomplete for tool names and type inference for inputs/outputs - similar to tRPC. This is opt-in and requires exporting your server type.
103
-
104
- > **Tip:** For the best TypeScript experience, use typed hooks throughout your application. They provide autocomplete, type safety, and better IDE support.
105
-
106
- > **Important:** For `generateHelpers` to work correctly, your MCP server must be defined using method chaining (e.g., `server.widget(...).widget(...).registerTool(...)`). This ensures TypeScript can properly infer the tool registry type from the chained calls.
107
-
108
- **Examples:**
109
-
110
- ✅ **Works** - Using method chaining:
111
-
112
- ```ts
113
- import { McpServer } from "skybridge/server";
114
- import { z } from "zod";
115
-
116
- const server = new McpServer({ name: "my-app", version: "1.0" }, {})
117
- .widget("search-voyage", {}, {
118
- inputSchema: { destination: z.string() },
119
- }, async ({ destination }) => {
120
- return { content: [{ type: "text", text: `Found trips to ${destination}` }] };
121
- })
122
- .registerTool("calculate-price", {
123
- inputSchema: { tripId: z.string() },
124
- }, async ({ tripId }) => {
125
- return { content: [{ type: "text", text: `Price for ${tripId}` }] };
126
- });
127
-
128
- export type AppType = typeof server; // ✅ Type inference works correctly
129
- ```
130
-
131
- ❌ **Doesn't work** - Without method chaining:
132
-
133
- ```ts
134
- import { McpServer } from "skybridge/server";
135
- import { z } from "zod";
136
-
137
- const server = new McpServer({ name: "my-app", version: "1.0" }, {});
138
-
139
- server.widget("search-voyage", {}, {
140
- inputSchema: { destination: z.string() },
141
- }, async ({ destination }) => {
142
- return { content: [{ type: "text", text: `Found trips to ${destination}` }] };
143
- });
144
-
145
- server.registerTool("calculate-price", {
146
- inputSchema: { tripId: z.string() },
147
- }, async ({ tripId }) => {
148
- return { content: [{ type: "text", text: `Price for ${tripId}` }] };
149
- });
150
-
151
- export type AppType = typeof server; // ❌ Type inference fails - tool registry is empty
152
- ```
153
-
154
- _Server setup (server/src/index.ts)_
155
-
156
- ```ts
157
- import { McpServer } from "skybridge/server";
158
- import { z } from "zod";
159
-
160
- const server = new McpServer({ name: "my-app", version: "1.0" }, {})
161
- .widget("search-voyage", {}, {
162
- description: "Search for trips",
163
- inputSchema: {
164
- destination: z.string(),
165
- departureDate: z.string().optional(),
166
- },
167
- outputSchema: {
168
- results: z.array(z.object({ id: z.string(), name: z.string() })),
169
- totalCount: z.number(),
170
- },
171
- }, async ({ destination }) => {
172
- // Your tool logic here...
173
- return { content: [{ type: "text", text: `Found trips to ${destination}` }] };
174
- })
175
- .widget("get-details", {}, {
176
- inputSchema: { tripId: z.string() },
177
- }, async ({ tripId }) => {
178
- return { content: [{ type: "text", text: `Details for ${tripId}` }] };
179
- });
180
-
181
- // Export the server type for the client
182
- export type AppType = typeof server;
183
- ```
184
-
185
- _One-time setup (web/src/skybridge.ts)_
186
-
187
- Create typed hooks once and export them for use across your app. This file acts as a bridge between your server types and your widgets:
188
-
189
- ```ts
190
- import type { AppType } from "../server"; // type-only import
191
- import { generateHelpers } from "skybridge/web";
192
-
193
- export const { useCallTool, useToolInfo } = generateHelpers<AppType>();
194
- ```
195
-
196
- _Usage in widgets (web/src/widgets/search.tsx)_
197
-
198
- ```tsx
199
- import { useCallTool, useToolInfo } from "../skybridge"; // import typed hooks
200
-
201
- export function SearchWidget() {
202
- const { callTool, data, isPending } = useCallTool("search-voyage");
203
- // ^ autocomplete for tool names
204
- const toolInfo = useToolInfo<"search-voyage">();
205
- // ^ autocomplete for widget names
206
-
207
- const handleSearch = () => {
208
- callTool({ destination: "Spain" });
209
- // ^ autocomplete for input fields
210
- };
211
-
212
- return (
213
- <div>
214
- <button onClick={handleSearch} disabled={isPending}>
215
- Search
216
- </button>
217
- {toolInfo.isSuccess && (
218
- <div>Found {toolInfo.output.structuredContent.totalCount} results</div>
219
- // ^ typed output
220
- )}
221
- </div>
222
- );
223
- }
224
- ```
225
-
226
- **Hooks**
227
-
228
- The `skybridge/web` package comes with a set of hooks to help you build your widgets :
229
-
230
- - `useOpenAiGlobal`: A generic hook to get any global data from the OpenAI iFrame skybridge runtime (in `window.openai`).
231
- - `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.
232
- - `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.
233
- - `useToolInfo`: A hook to get the tool input, output, and response metadata with type inference. Provides a discriminated union based on status (pending/success).
234
- - `useCallTool`: A @tanstack/react-query inspired hook to send make additional tool calls inside a widget.
235
- - `generateHelpers`: A factory that creates typed versions of `useCallTool` and `useToolInfo` with full type inference from your server type.
236
-
237
- _useOpenAiGlobal_
238
-
239
- ```ts
240
- import { useOpenAiGlobal } from "skybridge/web";
241
-
242
- const theme = useOpenAiGlobal("theme");
243
- ```
244
-
245
- _useToolOutput_
246
-
247
- ```ts
248
- import { useToolOutput } from "skybridge/web";
249
-
250
- const toolOutput = useToolOutput();
251
- ```
252
-
253
- _useToolResponseMetadata_
254
-
255
- ```ts
256
- import { useToolResponseMetadata } from "skybridge/web";
257
-
258
- const toolResponseMetadata = useToolResponseMetadata();
259
- ```
260
-
261
- _useToolInfo_
262
-
263
- ```ts
264
- import { useToolInfo } from "skybridge/web";
265
-
266
- const toolInfo = useToolInfo<{
267
- input: { query: string };
268
- output: { results: string[] };
269
- responseMetadata: { id: number };
270
- }>();
271
-
272
- // toolInfo.input is typed based on the input type
273
- // toolInfo.output.structuredContent is typed based on the output type (undefined when pending)
274
- // toolInfo.status narrows correctly: "pending" | "success"
275
-
276
- if (toolInfo.isPending) {
277
- // toolInfo.output is undefined here (pending state)
278
- console.log(toolInfo.input.query);
279
- }
280
-
281
- if (toolInfo.isSuccess) {
282
- // toolInfo.output.structuredContent is typed here
283
- console.log(toolInfo.output.structuredContent.results);
284
- }
285
- ```
286
-
287
- _useToolInfo_ with typed hooks (recommended)
288
-
289
- ```tsx
290
- import { useToolInfo } from "../skybridge"; // import typed hooks
291
-
292
- export function SearchWidget() {
293
- const toolInfo = useToolInfo<"search-voyage">();
294
- // ^ autocomplete for widget names
295
- // toolInfo.input is typed as { destination: string; departureDate?: string; ... }
296
- // toolInfo.output.structuredContent is typed as { results: Array<...>; totalCount: number; }
297
-
298
- if (toolInfo.isSuccess) {
299
- return <div>Found {toolInfo.output.structuredContent.totalCount} results</div>;
300
- }
301
-
302
- return <div>Searching for {toolInfo.input.destination}...</div>;
303
- }
304
- ```
305
-
306
- _useCallTool_ in synchronous mode
307
-
308
- ```ts
309
- import { useCallTool } from "skybridge/web";
310
-
311
- export const TestTool: React.FunctionComponent = () => {
312
- const { callTool, isPending } = useCallTool("myToolName");
313
-
314
- return (
315
- <div>
316
- <button
317
- disabled={isPending}
318
- onClick={() => {
319
- callTool({ input: "test input" }, {
320
- onSuccess: (data) => {
321
- alert("Tool returned: " + data);
322
- },
323
- });
324
- >
325
- Call Tool inside a widget
326
- </button>
327
- </div>
328
- );
329
- };
330
- ```
331
-
332
- _useCallTool_ in asynchronous mode
333
-
334
- ```ts
335
- import { useCallTool } from "skybridge/web";
336
-
337
- export const TestTool: React.FunctionComponent = () => {
338
- const { callToolAsync, isPending } = useCallTool("myToolName");
339
-
340
- return (
341
- <div>
342
- <button
343
- disabled={isPending}
344
- onClick={async () => {
345
- const data = await callToolAsync({ input: "test input" });
346
- alert("Tool returned: " + data);
347
- }}
348
- >
349
- Call Tool inside a widget
350
- </button>
351
- </div>
352
- );
353
- };
354
- ```
355
-
356
- ## Migrate your existing MCP server to a ChatGPT app
357
-
358
- If you're already using the `@modelcontextprotocol/sdk` to build a MCP server, you can migrate to a ChatGPT app by following these steps:
359
-
360
- 1. Replace your `McpServer` import from `@modelcontextprotocol/sdk` with the same import from `skybridge/server`
361
- 2. Create a new vite project in a folder named `web` and install the `skybridge` package
362
- 3. Replace the `vite.config.ts` file with the following:
363
-
364
- ```ts
365
- import { defineConfig } from "vite";
366
- import { skybridge } from "skybridge/web";
367
-
368
- export default defineConfig({
369
- plugins: [skybridge()],
370
- });
371
- ```
@@ -1,4 +0,0 @@
1
- /**
2
- * @deprecated This hook is deprecated. Use `useToolInfo()` instead and access the `output` property.
3
- */
4
- export declare function useToolOutput(): import("../types.js").UnknownObject | undefined;
@@ -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,4 +0,0 @@
1
- /**
2
- * @deprecated This hook is deprecated. Use `useToolInfo()` instead and access the `responseMetadata` property.
3
- */
4
- export declare function useToolResponseMetadata(): import("../types.js").UnknownObject | null | undefined;
@@ -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"}