skybridge 0.0.0-dev.d798b8b → 0.0.0-dev.d8629af

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 (202) hide show
  1. package/LICENSE +21 -674
  2. package/dist/src/server/devtoolsStaticServer.d.ts +19 -0
  3. package/dist/src/server/devtoolsStaticServer.js +48 -0
  4. package/dist/src/server/devtoolsStaticServer.js.map +1 -0
  5. package/dist/src/server/index.d.ts +3 -0
  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 +64 -0
  9. package/dist/src/server/inferUtilityTypes.js +2 -0
  10. package/dist/src/server/inferUtilityTypes.js.map +1 -0
  11. package/dist/src/server/server.d.ts +71 -9
  12. package/dist/src/server/server.js +65 -28
  13. package/dist/src/server/server.js.map +1 -1
  14. package/dist/src/server/templateHelper.d.ts +12 -8
  15. package/dist/src/server/templateHelper.js +5 -12
  16. package/dist/src/server/templateHelper.js.map +1 -1
  17. package/dist/src/server/templates/development.hbs +4 -2
  18. package/dist/src/server/templates/production.hbs +4 -2
  19. package/dist/src/server/widgetsDevServer.js +2 -3
  20. package/dist/src/server/widgetsDevServer.js.map +1 -1
  21. package/dist/src/test/utils.d.ts +108 -1
  22. package/dist/src/test/utils.js +202 -3
  23. package/dist/src/test/utils.js.map +1 -1
  24. package/dist/src/test/widget.test.js +102 -25
  25. package/dist/src/test/widget.test.js.map +1 -1
  26. package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.d.ts +13 -0
  27. package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.js +33 -0
  28. package/dist/src/web/bridges/adaptors/apps-sdk-adaptor.js.map +1 -0
  29. package/dist/src/web/bridges/adaptors/mcp-app-adaptor.d.ts +16 -0
  30. package/dist/src/web/bridges/adaptors/mcp-app-adaptor.js +115 -0
  31. package/dist/src/web/bridges/adaptors/mcp-app-adaptor.js.map +1 -0
  32. package/dist/src/web/bridges/apps-sdk-bridge.d.ts +10 -0
  33. package/dist/src/web/bridges/apps-sdk-bridge.js +46 -0
  34. package/dist/src/web/bridges/apps-sdk-bridge.js.map +1 -0
  35. package/dist/src/web/bridges/hooks/use-adaptor.d.ts +2 -0
  36. package/dist/src/web/bridges/hooks/use-adaptor.js +8 -0
  37. package/dist/src/web/bridges/hooks/use-adaptor.js.map +1 -0
  38. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.d.ts +2 -0
  39. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js +7 -0
  40. package/dist/src/web/bridges/hooks/use-apps-sdk-bridge.js.map +1 -0
  41. package/dist/src/web/bridges/hooks/use-bridge.d.ts +2 -0
  42. package/dist/src/web/bridges/hooks/use-bridge.js +8 -0
  43. package/dist/src/web/bridges/hooks/use-bridge.js.map +1 -0
  44. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.d.ts +5 -0
  45. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js +7 -0
  46. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.js.map +1 -0
  47. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js +41 -0
  48. package/dist/src/web/bridges/hooks/use-mcp-app-bridge.test.js.map +1 -0
  49. package/dist/src/web/bridges/index.d.ts +4 -0
  50. package/dist/src/web/bridges/index.js +5 -0
  51. package/dist/src/web/bridges/index.js.map +1 -0
  52. package/dist/src/web/bridges/mcp-app-bridge.d.ts +38 -0
  53. package/dist/src/web/bridges/mcp-app-bridge.js +162 -0
  54. package/dist/src/web/bridges/mcp-app-bridge.js.map +1 -0
  55. package/dist/src/web/bridges/types.d.ts +57 -0
  56. package/dist/src/web/bridges/types.js +2 -0
  57. package/dist/src/web/bridges/types.js.map +1 -0
  58. package/dist/src/web/create-store.d.ts +3 -0
  59. package/dist/src/web/create-store.js +25 -0
  60. package/dist/src/web/create-store.js.map +1 -0
  61. package/dist/src/web/create-store.test.js +70 -0
  62. package/dist/src/web/create-store.test.js.map +1 -0
  63. package/dist/src/web/data-llm.d.ts +14 -0
  64. package/dist/src/web/data-llm.js +70 -0
  65. package/dist/src/web/data-llm.js.map +1 -0
  66. package/dist/src/web/data-llm.test.d.ts +1 -0
  67. package/dist/src/web/data-llm.test.js +76 -0
  68. package/dist/src/web/data-llm.test.js.map +1 -0
  69. package/dist/src/web/generate-helpers.d.ts +115 -0
  70. package/dist/src/web/generate-helpers.js +111 -0
  71. package/dist/src/web/generate-helpers.js.map +1 -0
  72. package/dist/src/web/generate-helpers.test-d.d.ts +1 -0
  73. package/dist/src/web/generate-helpers.test-d.js +209 -0
  74. package/dist/src/web/generate-helpers.test-d.js.map +1 -0
  75. package/dist/src/web/generate-helpers.test.d.ts +1 -0
  76. package/dist/src/web/generate-helpers.test.js +17 -0
  77. package/dist/src/web/generate-helpers.test.js.map +1 -0
  78. package/dist/src/web/helpers/state.d.ts +7 -0
  79. package/dist/src/web/helpers/state.js +40 -0
  80. package/dist/src/web/helpers/state.js.map +1 -0
  81. package/dist/src/web/helpers/state.test.d.ts +1 -0
  82. package/dist/src/web/helpers/state.test.js +53 -0
  83. package/dist/src/web/helpers/state.test.js.map +1 -0
  84. package/dist/src/web/hooks/index.d.ts +11 -0
  85. package/dist/src/web/hooks/index.js +12 -0
  86. package/dist/src/web/hooks/index.js.map +1 -0
  87. package/dist/src/web/hooks/test/utils.d.ts +10 -0
  88. package/dist/src/web/hooks/test/utils.js +40 -0
  89. package/dist/src/web/hooks/test/utils.js.map +1 -0
  90. package/dist/src/web/hooks/use-call-tool.d.ts +100 -0
  91. package/dist/src/web/hooks/use-call-tool.js +68 -0
  92. package/dist/src/web/hooks/use-call-tool.js.map +1 -0
  93. package/dist/src/web/hooks/use-call-tool.test-d.d.ts +1 -0
  94. package/dist/src/web/hooks/use-call-tool.test-d.js +104 -0
  95. package/dist/src/web/hooks/use-call-tool.test-d.js.map +1 -0
  96. package/dist/src/web/hooks/use-call-tool.test.d.ts +1 -0
  97. package/dist/src/web/hooks/use-call-tool.test.js +191 -0
  98. package/dist/src/web/hooks/use-call-tool.test.js.map +1 -0
  99. package/dist/src/web/hooks/use-display-mode.d.ts +4 -0
  100. package/dist/src/web/hooks/use-display-mode.js +10 -0
  101. package/dist/src/web/hooks/use-display-mode.js.map +1 -0
  102. package/dist/src/web/hooks/use-display-mode.test.d.ts +1 -0
  103. package/dist/src/web/hooks/use-display-mode.test.js +41 -0
  104. package/dist/src/web/hooks/use-display-mode.test.js.map +1 -0
  105. package/dist/src/web/hooks/use-files.d.ts +10 -0
  106. package/dist/src/web/hooks/use-files.js +7 -0
  107. package/dist/src/web/hooks/use-files.js.map +1 -0
  108. package/dist/src/web/hooks/use-files.test.d.ts +1 -0
  109. package/dist/src/web/hooks/use-files.test.js +29 -0
  110. package/dist/src/web/hooks/use-files.test.js.map +1 -0
  111. package/dist/src/web/hooks/use-layout.d.ts +22 -0
  112. package/dist/src/web/hooks/use-layout.js +23 -0
  113. package/dist/src/web/hooks/use-layout.js.map +1 -0
  114. package/dist/src/web/hooks/use-layout.test.d.ts +1 -0
  115. package/dist/src/web/hooks/use-layout.test.js +95 -0
  116. package/dist/src/web/hooks/use-layout.test.js.map +1 -0
  117. package/dist/src/web/hooks/use-open-external.d.ts +1 -0
  118. package/dist/src/web/hooks/use-open-external.js +8 -0
  119. package/dist/src/web/hooks/use-open-external.js.map +1 -0
  120. package/dist/src/web/hooks/use-open-external.test.d.ts +1 -0
  121. package/dist/src/web/hooks/use-open-external.test.js +50 -0
  122. package/dist/src/web/hooks/use-open-external.test.js.map +1 -0
  123. package/dist/src/web/hooks/use-openai-global.d.ts +3 -0
  124. package/dist/src/web/hooks/use-openai-global.js +6 -0
  125. package/dist/src/web/hooks/use-openai-global.js.map +1 -0
  126. package/dist/src/web/hooks/use-request-modal.d.ts +9 -0
  127. package/dist/src/web/hooks/use-request-modal.js +14 -0
  128. package/dist/src/web/hooks/use-request-modal.js.map +1 -0
  129. package/dist/src/web/hooks/use-request-modal.test.d.ts +1 -0
  130. package/dist/src/web/hooks/use-request-modal.test.js +57 -0
  131. package/dist/src/web/hooks/use-request-modal.test.js.map +1 -0
  132. package/dist/src/web/hooks/use-send-follow-up-message.d.ts +1 -0
  133. package/dist/src/web/hooks/use-send-follow-up-message.js +8 -0
  134. package/dist/src/web/hooks/use-send-follow-up-message.js.map +1 -0
  135. package/dist/src/web/hooks/use-tool-info.d.ts +36 -0
  136. package/dist/src/web/hooks/use-tool-info.js +26 -0
  137. package/dist/src/web/hooks/use-tool-info.js.map +1 -0
  138. package/dist/src/web/hooks/use-tool-info.test-d.d.ts +1 -0
  139. package/dist/src/web/hooks/use-tool-info.test-d.js +109 -0
  140. package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -0
  141. package/dist/src/web/hooks/use-tool-info.test.d.ts +1 -0
  142. package/dist/src/web/hooks/use-tool-info.test.js +130 -0
  143. package/dist/src/web/hooks/use-tool-info.test.js.map +1 -0
  144. package/dist/src/web/hooks/use-user.d.ts +18 -0
  145. package/dist/src/web/hooks/use-user.js +19 -0
  146. package/dist/src/web/hooks/use-user.js.map +1 -0
  147. package/dist/src/web/hooks/use-user.test.d.ts +1 -0
  148. package/dist/src/web/hooks/use-user.test.js +93 -0
  149. package/dist/src/web/hooks/use-user.test.js.map +1 -0
  150. package/dist/src/web/hooks/use-widget-state.d.ts +4 -0
  151. package/dist/src/web/hooks/use-widget-state.js +32 -0
  152. package/dist/src/web/hooks/use-widget-state.js.map +1 -0
  153. package/dist/src/web/hooks/use-widget-state.test.d.ts +1 -0
  154. package/dist/src/web/hooks/use-widget-state.test.js +61 -0
  155. package/dist/src/web/hooks/use-widget-state.test.js.map +1 -0
  156. package/dist/src/web/index.d.ts +7 -6
  157. package/dist/src/web/index.js +7 -6
  158. package/dist/src/web/index.js.map +1 -1
  159. package/dist/src/web/mount-widget.js +5 -0
  160. package/dist/src/web/mount-widget.js.map +1 -1
  161. package/dist/src/web/plugin/data-llm.test.d.ts +1 -0
  162. package/dist/src/web/plugin/data-llm.test.js +81 -0
  163. package/dist/src/web/plugin/data-llm.test.js.map +1 -0
  164. package/dist/src/web/plugin/plugin.js +39 -0
  165. package/dist/src/web/plugin/plugin.js.map +1 -0
  166. package/dist/src/web/plugin/transform-data-llm.d.ts +12 -0
  167. package/dist/src/web/plugin/transform-data-llm.js +96 -0
  168. package/dist/src/web/plugin/transform-data-llm.js.map +1 -0
  169. package/dist/src/web/plugin/transform-data-llm.test.d.ts +1 -0
  170. package/dist/src/web/plugin/transform-data-llm.test.js +81 -0
  171. package/dist/src/web/plugin/transform-data-llm.test.js.map +1 -0
  172. package/dist/src/web/proxy.d.ts +1 -0
  173. package/dist/src/web/proxy.js +53 -0
  174. package/dist/src/web/proxy.js.map +1 -0
  175. package/dist/src/web/types.d.ts +68 -22
  176. package/dist/src/web/types.js +1 -0
  177. package/dist/src/web/types.js.map +1 -1
  178. package/dist/vitest.config.js +0 -1
  179. package/dist/vitest.config.js.map +1 -1
  180. package/package.json +27 -13
  181. package/README.md +0 -126
  182. package/dist/src/test/setup.js +0 -9
  183. package/dist/src/test/setup.js.map +0 -1
  184. package/dist/src/web/plugin.js +0 -30
  185. package/dist/src/web/plugin.js.map +0 -1
  186. package/dist/src/web/use-call-tool.d.ts +0 -54
  187. package/dist/src/web/use-call-tool.js +0 -67
  188. package/dist/src/web/use-call-tool.js.map +0 -1
  189. package/dist/src/web/use-call-tool.test.js +0 -66
  190. package/dist/src/web/use-call-tool.test.js.map +0 -1
  191. package/dist/src/web/use-openai-global.d.ts +0 -2
  192. package/dist/src/web/use-openai-global.js +0 -21
  193. package/dist/src/web/use-openai-global.js.map +0 -1
  194. package/dist/src/web/use-tool-output.d.ts +0 -3
  195. package/dist/src/web/use-tool-output.js +0 -5
  196. package/dist/src/web/use-tool-output.js.map +0 -1
  197. package/dist/src/web/use-tool-response-metadata.d.ts +0 -3
  198. package/dist/src/web/use-tool-response-metadata.js +0 -5
  199. package/dist/src/web/use-tool-response-metadata.js.map +0 -1
  200. /package/dist/src/{test/setup.d.ts → web/bridges/hooks/use-mcp-app-bridge.test.d.ts} +0 -0
  201. /package/dist/src/web/{use-call-tool.test.d.ts → create-store.test.d.ts} +0 -0
  202. /package/dist/src/web/{plugin.d.ts → plugin/plugin.d.ts} +0 -0
@@ -1,14 +1,24 @@
1
- type UnknownObject = Record<string, unknown>;
2
- export type WidgetState = UnknownObject;
3
- export type SetWidgetState = (state: WidgetState) => Promise<void>;
4
- export type SendFollowUpMessage = (args: {
5
- prompt: string;
6
- }) => Promise<void>;
7
- export type RequestDisplayMode = (args: {
8
- mode: DisplayMode;
9
- }) => Promise<{
10
- mode: DisplayMode;
11
- }>;
1
+ import "react";
2
+ import type { CallToolResult } from "@modelcontextprotocol/sdk/types.js";
3
+ import type { WidgetHostType } from "../server/index.js";
4
+ declare module "react" {
5
+ interface HTMLAttributes<T> {
6
+ "data-llm"?: string;
7
+ }
8
+ }
9
+ export type UnknownObject = Record<string, unknown>;
10
+ export type Prettify<T> = {
11
+ [K in keyof T]: T[K];
12
+ } & {};
13
+ export type Objectify<T> = T & UnknownObject;
14
+ type RequiredKeys<T> = {
15
+ [K in keyof T]-?: Record<string, never> extends Pick<T, K> ? never : K;
16
+ }[keyof T];
17
+ export type HasRequiredKeys<T> = RequiredKeys<T> extends never ? false : true;
18
+ type WidgetState = UnknownObject;
19
+ type FileMetadata = {
20
+ fileId: string;
21
+ };
12
22
  export declare const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
13
23
  export declare class ToolResponseEvent extends CustomEvent<{
14
24
  tool: {
@@ -20,36 +30,50 @@ export declare class ToolResponseEvent extends CustomEvent<{
20
30
  }
21
31
  declare global {
22
32
  interface Window {
23
- openai: API<WidgetState> & OpenAiGlobals;
33
+ skybridge: SkybridgeProperties;
34
+ openai: OpenAiMethods<WidgetState> & OpenAiProperties;
24
35
  }
25
36
  interface WindowEventMap {
26
37
  [SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
27
38
  }
28
39
  }
29
- export type OpenAiGlobals<ToolInput extends UnknownObject = UnknownObject, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
40
+ export type SkybridgeProperties = {
41
+ hostType: WidgetHostType;
42
+ };
43
+ export type OpenAiProperties<ToolInput extends UnknownObject = Record<never, unknown>, ToolOutput extends UnknownObject = UnknownObject, ToolResponseMetadata extends UnknownObject = UnknownObject, WidgetState extends UnknownObject = UnknownObject> = {
30
44
  theme: Theme;
31
45
  userAgent: UserAgent;
32
46
  locale: string;
33
47
  maxHeight: number;
34
48
  displayMode: DisplayMode;
35
49
  safeArea: SafeArea;
50
+ view: View;
36
51
  toolInput: ToolInput;
37
- toolOutput: ToolOutput | null;
52
+ toolOutput: ToolOutput | {
53
+ text: string;
54
+ } | null;
38
55
  toolResponseMetadata: ToolResponseMetadata | null;
39
56
  widgetState: WidgetState | null;
40
57
  };
41
58
  export type CallToolArgs = Record<string, unknown> | null;
42
59
  export type CallToolResponse = {
43
- content: {
44
- type: "text";
45
- text: string;
46
- }[];
60
+ content: CallToolResult["content"];
47
61
  structuredContent: Record<string, unknown>;
48
62
  isError: boolean;
49
63
  result: string;
50
64
  meta: Record<string, unknown>;
51
65
  };
52
- type API<WidgetState extends UnknownObject> = {
66
+ export type RequestModalOptions = {
67
+ title?: string;
68
+ params?: Record<string, unknown>;
69
+ anchor?: {
70
+ top?: number;
71
+ left?: number;
72
+ width?: number;
73
+ height?: number;
74
+ };
75
+ };
76
+ export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
53
77
  /** Calls a tool on your MCP. Returns the full response. */
54
78
  callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
55
79
  /** Triggers a followup turn in the ChatGPT conversation */
@@ -57,7 +81,7 @@ type API<WidgetState extends UnknownObject> = {
57
81
  prompt: string;
58
82
  }) => Promise<void>;
59
83
  /** Opens an external link, redirects web page or mobile app */
60
- openExternal(payload: {
84
+ openExternal(args: {
61
85
  href: string;
62
86
  }): void;
63
87
  /** For transitioning an app from inline to fullscreen or pip */
@@ -70,16 +94,38 @@ type API<WidgetState extends UnknownObject> = {
70
94
  */
71
95
  mode: DisplayMode;
72
96
  }>;
97
+ /**
98
+ * Sets the widget state.
99
+ * This state is persisted across widget renders.
100
+ */
73
101
  setWidgetState: (state: WidgetState) => Promise<void>;
102
+ /**
103
+ * Opens a modal portaled outside of the widget iFrame.
104
+ * This ensures the modal is correctly displayed and not limited to the widget's area.
105
+ */
106
+ requestModal: (args: RequestModalOptions) => Promise<void>;
107
+ /** Uploads a new file to the host */
108
+ uploadFile: (file: File) => Promise<FileMetadata>;
109
+ /**
110
+ * Downloads a file from the host that was previously uploaded.
111
+ * Only files uploaded by the same connector instance can be downloaded.
112
+ */
113
+ downloadFile: (file: FileMetadata) => Promise<{
114
+ downloadUrl: string;
115
+ }>;
74
116
  };
75
117
  export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
76
118
  export declare class SetGlobalsEvent extends CustomEvent<{
77
- globals: Partial<OpenAiGlobals>;
119
+ globals: Partial<OpenAiProperties>;
78
120
  }> {
79
121
  readonly type = "openai:set_globals";
80
122
  }
81
123
  export type CallTool = (name: string, args: Record<string, unknown>) => Promise<CallToolResponse>;
82
- export type DisplayMode = "pip" | "inline" | "fullscreen";
124
+ export type DisplayMode = "pip" | "inline" | "fullscreen" | "modal";
125
+ export type View = {
126
+ mode: DisplayMode;
127
+ params?: Record<string, unknown>;
128
+ };
83
129
  export type Theme = "light" | "dark";
84
130
  export type SafeAreaInsets = {
85
131
  top: number;
@@ -1,3 +1,4 @@
1
+ import "react";
1
2
  export const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
2
3
  export class ToolResponseEvent extends CustomEvent {
3
4
  type = TOOL_RESPONSE_EVENT_TYPE;
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"AAYA,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AA2ED,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,MAAM,OAAO,eAAgB,SAAQ,WAEnC;IACkB,IAAI,GAAG,sBAAsB,CAAC;CACjD"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/web/types.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,CAAC;AAyBf,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAAsB,CAAC;AAC/D,MAAM,OAAO,iBAAkB,SAAQ,WAErC;IACkB,IAAI,GAAG,wBAAwB,CAAC;CACnD;AAuGD,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,oBAAoB,CAAC;AAC3D,MAAM,OAAO,eAAgB,SAAQ,WAEnC;IACkB,IAAI,GAAG,sBAAsB,CAAC;CACjD"}
@@ -3,7 +3,6 @@ export default defineConfig({
3
3
  test: {
4
4
  environment: "jsdom",
5
5
  globals: true,
6
- setupFiles: ["./src/test/setup.ts"],
7
6
  },
8
7
  });
9
8
  //# sourceMappingURL=vitest.config.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,IAAI;QACb,UAAU,EAAE,CAAC,qBAAqB,CAAC;KACpC;CACF,CAAC,CAAC"}
1
+ {"version":3,"file":"vitest.config.js","sourceRoot":"","sources":["../vitest.config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,eAAe,YAAY,CAAC;IAC1B,IAAI,EAAE;QACJ,WAAW,EAAE,OAAO;QACpB,OAAO,EAAE,IAAI;KACd;CACF,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,11 @@
1
1
  {
2
2
  "name": "skybridge",
3
- "version": "0.0.0-dev.d798b8b",
3
+ "version": "0.0.0-dev.d8629af",
4
4
  "description": "Skybridge is a framework for building ChatGPT apps",
5
+ "repository": {
6
+ "type": "git",
7
+ "url": "https://github.com/alpic-ai/skybridge.git"
8
+ },
5
9
  "type": "module",
6
10
  "files": [
7
11
  "dist"
@@ -16,11 +20,6 @@
16
20
  "default": "./dist/src/web/index.js"
17
21
  }
18
22
  },
19
- "scripts": {
20
- "build": "tsc && pnpm run build:templates",
21
- "build:templates": "cp -r src/server/templates dist/src/server/",
22
- "test": "vitest run --silent"
23
- },
24
23
  "keywords": [
25
24
  "chatgpt",
26
25
  "app",
@@ -30,31 +29,46 @@
30
29
  "author": "Frédéric Barthelet",
31
30
  "license": "ISC",
32
31
  "peerDependencies": {
32
+ "@modelcontextprotocol/sdk": ">=1.0.0",
33
33
  "react": ">=18.0.0",
34
34
  "react-dom": ">=18.0.0"
35
35
  },
36
36
  "dependencies": {
37
- "@modelcontextprotocol/sdk": "^1.20.0",
37
+ "@babel/core": "^7.28.5",
38
38
  "cors": "^2.8.5",
39
+ "dequal": "^2.0.3",
39
40
  "express": "^5.1.0",
40
41
  "handlebars": "^4.7.8",
42
+ "superjson": "^2.2.6",
41
43
  "vite": "^7.1.11",
42
- "zod": "^3.25.51"
44
+ "zustand": "^5.0.9"
43
45
  },
44
46
  "devDependencies": {
47
+ "@modelcontextprotocol/ext-apps": "^0.2.2",
48
+ "@modelcontextprotocol/sdk": "^1.24.3",
45
49
  "@testing-library/dom": "^10.4.1",
46
- "@testing-library/react": "^16.3.0",
50
+ "@testing-library/react": "^16.3.1",
47
51
  "@total-typescript/tsconfig": "^1.0.4",
52
+ "@types/babel__core": "^7.20.5",
48
53
  "@types/cors": "^2.8.19",
49
54
  "@types/express": "^5.0.3",
50
- "@types/jsdom": "^21.1.6",
55
+ "@types/jsdom": "^21.1.7",
51
56
  "@types/node": "^22.15.30",
52
57
  "@types/react": "^19.2.2",
53
58
  "@types/react-dom": "^19.2.2",
54
59
  "@vitest/ui": "^2.1.8",
55
60
  "jsdom": "^25.0.1",
56
61
  "typescript": "^5.9.3",
57
- "vitest": "^2.1.8"
62
+ "vitest": "^2.1.8",
63
+ "zod": "^4.1.13"
58
64
  },
59
- "packageManager": "pnpm@10.17.1"
60
- }
65
+ "scripts": {
66
+ "build": "tsc && pnpm run build:templates",
67
+ "build:templates": "cp -r src/server/templates dist/src/server/",
68
+ "format": "biome check --write --error-on-warnings",
69
+ "test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
70
+ "test:unit": "vitest run",
71
+ "test:type": "tsc --noEmit",
72
+ "test:format": "biome ci"
73
+ }
74
+ }
package/README.md DELETED
@@ -1,126 +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
- **Hooks**
101
-
102
- The `skybridge/web` package comes with a set of hooks to help you build your widgets.
103
-
104
- ```ts
105
- import { useToolOutput } from "skybridge/web";
106
-
107
- // Initial data returned by the tool invocation on structuredOutput
108
- const toolOutput = useToolOutput();
109
- ```
110
-
111
- ## Migrate your existing MCP server to a ChatGPT app
112
-
113
- If you're already using the `@modelcontextprotocol/sdk` to build a MCP server, you can migrate to a ChatGPT app by following these steps:
114
-
115
- 1. Replace your `McpServer` import from `@modelcontextprotocol/sdk` with the same import from `skybridge/server`
116
- 2. Create a new vite project in a folder named `web` and install the `skybridge` package
117
- 3. Replace the `vite.config.ts` file with the following:
118
-
119
- ```ts
120
- import { defineConfig } from "vite";
121
- import { skybridge } from "skybridge/web";
122
-
123
- export default defineConfig({
124
- plugins: [skybridge()],
125
- });
126
- ```
@@ -1,9 +0,0 @@
1
- import { vi } from "vitest";
2
- // Mock console methods to avoid noise in tests
3
- global.console = {
4
- ...console,
5
- error: vi.fn(),
6
- warn: vi.fn(),
7
- log: vi.fn(),
8
- };
9
- //# sourceMappingURL=setup.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"setup.js","sourceRoot":"","sources":["../../../src/test/setup.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE5B,+CAA+C;AAC/C,MAAM,CAAC,OAAO,GAAG;IACf,GAAG,OAAO;IACV,KAAK,EAAE,EAAE,CAAC,EAAE,EAAE;IACd,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;IACb,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;CACb,CAAC"}
@@ -1,30 +0,0 @@
1
- export function skybridge() {
2
- return {
3
- name: "skybridge",
4
- async config(config) {
5
- // Dynamic imports to ensure Node modules are only loaded in Node.js context
6
- const { globSync } = await import("node:fs");
7
- const { resolve } = await import("node:path");
8
- const projectRoot = config.root || process.cwd();
9
- const widgetsPattern = resolve(projectRoot, "src/widgets/*.{js,ts,jsx,tsx,html}");
10
- const input = Object.fromEntries(globSync(widgetsPattern).map((file) => [
11
- file.match(/src\/widgets\/(.+)\.tsx$/)?.[1],
12
- file,
13
- ]));
14
- return {
15
- build: {
16
- minify: true,
17
- cssCodeSplit: false,
18
- rollupOptions: {
19
- input,
20
- output: {
21
- entryFileNames: "[name].js",
22
- assetFileNames: "[name][extname]",
23
- },
24
- },
25
- },
26
- };
27
- },
28
- };
29
- }
30
- //# sourceMappingURL=plugin.js.map
@@ -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,KAAK,EAAE;oBACL,MAAM,EAAE,IAAI;oBACZ,YAAY,EAAE,KAAK;oBACnB,aAAa,EAAE;wBACb,KAAK;wBACL,MAAM,EAAE;4BACN,cAAc,EAAE,WAAW;4BAC3B,cAAc,EAAE,iBAAiB;yBAClC;qBACF;iBACF;aACF,CAAC;QACJ,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -1,54 +0,0 @@
1
- import type { CallToolArgs, CallToolResponse } from "./types.js";
2
- export declare const useCallTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string) => {
3
- callTool: (toolArgs: ToolArgs, sideEffects?: {
4
- onSuccess?: (data: ToolResponse, toolArgs: ToolArgs) => void;
5
- onError?: (error: unknown, toolArgs: ToolArgs) => void;
6
- }) => void;
7
- callToolAsync: (toolArgs: ToolArgs) => Promise<ToolResponse>;
8
- status: "idle";
9
- data: undefined;
10
- error: undefined;
11
- isIdle: true;
12
- isPending: false;
13
- isSuccess: false;
14
- isError: false;
15
- } | {
16
- callTool: (toolArgs: ToolArgs, sideEffects?: {
17
- onSuccess?: (data: ToolResponse, toolArgs: ToolArgs) => void;
18
- onError?: (error: unknown, toolArgs: ToolArgs) => void;
19
- }) => void;
20
- callToolAsync: (toolArgs: ToolArgs) => Promise<ToolResponse>;
21
- status: "pending";
22
- data: undefined;
23
- error: undefined;
24
- isIdle: false;
25
- isPending: true;
26
- isSuccess: false;
27
- isError: false;
28
- } | {
29
- callTool: (toolArgs: ToolArgs, sideEffects?: {
30
- onSuccess?: (data: ToolResponse, toolArgs: ToolArgs) => void;
31
- onError?: (error: unknown, toolArgs: ToolArgs) => void;
32
- }) => void;
33
- callToolAsync: (toolArgs: ToolArgs) => Promise<ToolResponse>;
34
- status: "error";
35
- data: undefined;
36
- error: unknown;
37
- isIdle: false;
38
- isPending: false;
39
- isSuccess: false;
40
- isError: true;
41
- } | {
42
- callTool: (toolArgs: ToolArgs, sideEffects?: {
43
- onSuccess?: (data: ToolResponse, toolArgs: ToolArgs) => void;
44
- onError?: (error: unknown, toolArgs: ToolArgs) => void;
45
- }) => void;
46
- callToolAsync: (toolArgs: ToolArgs) => Promise<ToolResponse>;
47
- status: "success";
48
- data: ToolResponse;
49
- error: undefined;
50
- isIdle: false;
51
- isPending: false;
52
- isSuccess: true;
53
- isError: false;
54
- };
@@ -1,67 +0,0 @@
1
- import { useState } from "react";
2
- export const useCallTool = (name) => {
3
- const [callToolState, setCallToolState] = useState({
4
- status: "idle",
5
- data: undefined,
6
- error: undefined,
7
- isIdle: true,
8
- isPending: false,
9
- isSuccess: false,
10
- isError: false,
11
- });
12
- const callToolAsync = async (toolArgs) => {
13
- setCallToolState({
14
- status: "pending",
15
- data: undefined,
16
- error: undefined,
17
- isIdle: false,
18
- isPending: true,
19
- isSuccess: false,
20
- isError: false,
21
- });
22
- try {
23
- const data = await window.openai.callTool(name, toolArgs);
24
- setCallToolState({
25
- status: "success",
26
- data,
27
- error: undefined,
28
- isIdle: false,
29
- isPending: false,
30
- isSuccess: true,
31
- isError: false,
32
- });
33
- return data;
34
- }
35
- catch (error) {
36
- setCallToolState({
37
- status: "error",
38
- data: undefined,
39
- error,
40
- isIdle: false,
41
- isPending: false,
42
- isSuccess: false,
43
- isError: true,
44
- });
45
- throw error;
46
- }
47
- };
48
- const callTool = (toolArgs, sideEffects) => {
49
- callToolAsync(toolArgs)
50
- .then((data) => {
51
- if (sideEffects?.onSuccess) {
52
- sideEffects.onSuccess(data, toolArgs);
53
- }
54
- })
55
- .catch((error) => {
56
- if (sideEffects?.onError) {
57
- sideEffects.onError(error, toolArgs);
58
- }
59
- });
60
- };
61
- return {
62
- ...callToolState,
63
- callTool,
64
- callToolAsync,
65
- };
66
- };
67
- //# sourceMappingURL=use-call-tool.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-call-tool.js","sourceRoot":"","sources":["../../../src/web/use-call-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AA+CjC,MAAM,CAAC,MAAM,WAAW,GAAG,CAIzB,IAAY,EACZ,EAAE;IACF,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAEhD;QACA,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,IAAI;QACZ,SAAS,EAAE,KAAK;QAChB,SAAS,EAAE,KAAK;QAChB,OAAO,EAAE,KAAK;KACf,CAAC,CAAC;IAEH,MAAM,aAAa,GAAG,KAAK,EAAE,QAAkB,EAAE,EAAE;QACjD,gBAAgB,CAAC;YACf,MAAM,EAAE,SAAS;YACjB,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,KAAK;YACb,SAAS,EAAE,IAAI;YACf,SAAS,EAAE,KAAK;YAChB,OAAO,EAAE,KAAK;SACf,CAAC,CAAC;QACH,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CACvC,IAAI,EACJ,QAAQ,CACT,CAAC;YACF,gBAAgB,CAAC;gBACf,MAAM,EAAE,SAAS;gBACjB,IAAI;gBACJ,KAAK,EAAE,SAAS;gBAChB,MAAM,EAAE,KAAK;gBACb,SAAS,EAAE,KAAK;gBAChB,SAAS,EAAE,IAAI;gBACf,OAAO,EAAE,KAAK;aACf,CAAC,CAAC;YAEH,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,gBAAgB,CAAC;gBACf,MAAM,EAAE,OAAO;gBACf,IAAI,EAAE,SAAS;gBACf,KAAK;gBACL,MAAM,EAAE,KAAK;gBACb,SAAS,EAAE,KAAK;gBAChB,SAAS,EAAE,KAAK;gBAChB,OAAO,EAAE,IAAI;aACd,CAAC,CAAC;YACH,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,QAAQ,GAAG,CACf,QAAkB,EAClB,WAGC,EACD,EAAE;QACF,aAAa,CAAC,QAAQ,CAAC;aACpB,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE;YACb,IAAI,WAAW,EAAE,SAAS,EAAE,CAAC;gBAC3B,WAAW,CAAC,SAAS,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC;YACxC,CAAC;QACH,CAAC,CAAC;aACD,KAAK,CAAC,CAAC,KAAK,EAAE,EAAE;YACf,IAAI,WAAW,EAAE,OAAO,EAAE,CAAC;gBACzB,WAAW,CAAC,OAAO,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC;YACvC,CAAC;QACH,CAAC,CAAC,CAAC;IACP,CAAC,CAAC;IAEF,OAAO;QACL,GAAG,aAAa;QAChB,QAAQ;QACR,aAAa;KACd,CAAC;AACJ,CAAC,CAAC"}
@@ -1,66 +0,0 @@
1
- import { useCallTool } from "./use-call-tool.js";
2
- import { describe, it, expect, vi, beforeEach, afterEach, } from "vitest";
3
- import { renderHook, act, waitFor } from "@testing-library/react";
4
- describe("useCallTool - onSuccess callback", () => {
5
- let OpenaiMock;
6
- beforeEach(() => {
7
- OpenaiMock = {
8
- callTool: vi.fn(),
9
- };
10
- vi.stubGlobal("openai", OpenaiMock);
11
- });
12
- afterEach(() => {
13
- vi.unstubAllGlobals();
14
- vi.resetAllMocks();
15
- });
16
- const toolName = "test-tool";
17
- const args = { input: "test input" };
18
- const data = {
19
- content: [{ type: "text", text: "test result" }],
20
- structuredContent: { result: "test" },
21
- isError: false,
22
- result: "test result",
23
- meta: {},
24
- };
25
- const error = new Error("test error");
26
- it("should call window.openai.callTool with correct arguments", async () => {
27
- const { result } = renderHook(() => useCallTool(toolName));
28
- act(() => {
29
- result.current.callTool(args);
30
- });
31
- expect(OpenaiMock.callTool).toHaveBeenCalledWith(toolName, args);
32
- });
33
- it("should call onSuccess callback with correct data and toolArgs on successful execution", async () => {
34
- const onSuccess = vi.fn();
35
- const onError = vi.fn();
36
- OpenaiMock.callTool.mockResolvedValueOnce(data);
37
- const { result } = renderHook(() => useCallTool(toolName));
38
- act(() => {
39
- result.current.callTool(args, {
40
- onSuccess,
41
- onError,
42
- });
43
- });
44
- await waitFor(() => {
45
- expect(onSuccess).toHaveBeenCalledWith(data, args);
46
- expect(onError).not.toHaveBeenCalled();
47
- });
48
- });
49
- it("should call onError callback with error and toolArgs on failed execution", async () => {
50
- const onSuccess = vi.fn();
51
- const onError = vi.fn();
52
- OpenaiMock.callTool.mockRejectedValueOnce(error);
53
- const { result } = renderHook(() => useCallTool(toolName));
54
- act(() => {
55
- result.current.callTool(args, {
56
- onSuccess,
57
- onError,
58
- });
59
- });
60
- await waitFor(() => {
61
- expect(onSuccess).not.toHaveBeenCalled();
62
- expect(onError).toHaveBeenCalledWith(error, args);
63
- });
64
- });
65
- });
66
- //# sourceMappingURL=use-call-tool.test.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-call-tool.test.js","sourceRoot":"","sources":["../../../src/web/use-call-tool.test.ts"],"names":[],"mappings":"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"}
@@ -1,2 +0,0 @@
1
- import { type OpenAiGlobals } from "./types.js";
2
- export declare function useOpenAiGlobal<K extends keyof OpenAiGlobals>(key: K): OpenAiGlobals[K] | undefined;
@@ -1,21 +0,0 @@
1
- import { useSyncExternalStore } from "react";
2
- import { SET_GLOBALS_EVENT_TYPE, SetGlobalsEvent } from "./types.js";
3
- export function useOpenAiGlobal(key) {
4
- return useSyncExternalStore((onChange) => {
5
- const handleSetGlobal = (event) => {
6
- const value = event.detail.globals[key];
7
- if (value === undefined) {
8
- return;
9
- }
10
- console.dir(event.detail.globals, { depth: Infinity });
11
- onChange();
12
- };
13
- window.addEventListener(SET_GLOBALS_EVENT_TYPE, handleSetGlobal, {
14
- passive: true,
15
- });
16
- return () => {
17
- window.removeEventListener(SET_GLOBALS_EVENT_TYPE, handleSetGlobal);
18
- };
19
- }, () => window.openai?.[key]);
20
- }
21
- //# sourceMappingURL=use-openai-global.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"use-openai-global.js","sourceRoot":"","sources":["../../../src/web/use-openai-global.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,OAAO,CAAC;AAC7C,OAAO,EAAE,sBAAsB,EAAE,eAAe,EAAsB,MAAM,YAAY,CAAC;AAEzF,MAAM,UAAU,eAAe,CAAgC,GAAM;IACnE,OAAO,oBAAoB,CACzB,CAAC,QAAQ,EAAE,EAAE;QACX,MAAM,eAAe,GAAG,CAAC,KAAsB,EAAE,EAAE;YACjD,MAAM,KAAK,GAAG,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACxC,IAAI,KAAK,KAAK,SAAS,EAAE,CAAC;gBACxB,OAAO;YACT,CAAC;YAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC,CAAC;YACvD,QAAQ,EAAE,CAAC;QACb,CAAC,CAAC;QAEF,MAAM,CAAC,gBAAgB,CAAC,sBAAsB,EAAE,eAAe,EAAE;YAC/D,OAAO,EAAE,IAAI;SACd,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,MAAM,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,eAAe,CAAC,CAAC;QACtE,CAAC,CAAC;IACJ,CAAC,EACD,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAC3B,CAAC;AACJ,CAAC"}
@@ -1,3 +0,0 @@
1
- export declare function useToolOutput(): {
2
- [x: string]: unknown;
3
- } | null | undefined;