skybridge 0.0.0-dev.e31f406 → 0.0.0-dev.e3e0986

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 (132) hide show
  1. package/README.md +122 -0
  2. package/dist/src/server/index.d.ts +2 -0
  3. package/dist/src/server/inferUtilityTypes.d.ts +33 -0
  4. package/dist/src/server/inferUtilityTypes.js +2 -0
  5. package/dist/src/server/inferUtilityTypes.js.map +1 -0
  6. package/dist/src/server/server.d.ts +14 -7
  7. package/dist/src/server/server.js +20 -7
  8. package/dist/src/server/server.js.map +1 -1
  9. package/dist/src/server/templateHelper.d.ts +9 -8
  10. package/dist/src/server/templateHelper.js +0 -8
  11. package/dist/src/server/templateHelper.js.map +1 -1
  12. package/dist/src/server/templates/development.hbs +1 -0
  13. package/dist/src/server/templates/production.hbs +3 -2
  14. package/dist/src/test/utils.js +1 -1
  15. package/dist/src/test/utils.js.map +1 -1
  16. package/dist/src/test/widget.test.js +23 -2
  17. package/dist/src/test/widget.test.js.map +1 -1
  18. package/dist/src/web/hooks/index.d.ts +14 -0
  19. package/dist/src/web/hooks/index.js +15 -0
  20. package/dist/src/web/hooks/index.js.map +1 -0
  21. package/dist/src/web/hooks/use-call-tool.d.ts +62 -0
  22. package/dist/src/web/{use-call-tool.js → hooks/use-call-tool.js} +28 -4
  23. package/dist/src/web/hooks/use-call-tool.js.map +1 -0
  24. package/dist/src/web/hooks/use-call-tool.test.js +163 -0
  25. package/dist/src/web/hooks/use-call-tool.test.js.map +1 -0
  26. package/dist/src/web/hooks/use-display-mode.d.ts +4 -0
  27. package/dist/src/web/hooks/use-display-mode.js +7 -0
  28. package/dist/src/web/hooks/use-display-mode.js.map +1 -0
  29. package/dist/src/web/hooks/use-display-mode.test.js +40 -0
  30. package/dist/src/web/hooks/use-display-mode.test.js.map +1 -0
  31. package/dist/src/web/hooks/use-files.d.ts +10 -0
  32. package/dist/src/web/hooks/use-files.js +7 -0
  33. package/dist/src/web/hooks/use-files.js.map +1 -0
  34. package/dist/src/web/hooks/use-files.test.d.ts +1 -0
  35. package/dist/src/web/hooks/use-files.test.js +29 -0
  36. package/dist/src/web/hooks/use-files.test.js.map +1 -0
  37. package/dist/src/web/hooks/use-locale.d.ts +1 -0
  38. package/dist/src/web/hooks/use-locale.js +5 -0
  39. package/dist/src/web/hooks/use-locale.js.map +1 -0
  40. package/dist/src/web/hooks/use-locale.test.d.ts +1 -0
  41. package/dist/src/web/hooks/use-locale.test.js +21 -0
  42. package/dist/src/web/hooks/use-locale.test.js.map +1 -0
  43. package/dist/src/web/hooks/use-open-external.d.ts +1 -0
  44. package/dist/src/web/hooks/use-open-external.js +6 -0
  45. package/dist/src/web/hooks/use-open-external.js.map +1 -0
  46. package/dist/src/web/hooks/use-open-external.test.d.ts +1 -0
  47. package/dist/src/web/hooks/use-open-external.test.js +24 -0
  48. package/dist/src/web/hooks/use-open-external.test.js.map +1 -0
  49. package/dist/src/web/{use-openai-global.d.ts → hooks/use-openai-global.d.ts} +1 -1
  50. package/dist/src/web/{use-openai-global.js → hooks/use-openai-global.js} +4 -2
  51. package/dist/src/web/hooks/use-openai-global.js.map +1 -0
  52. package/dist/src/web/hooks/use-request-modal.d.ts +6 -0
  53. package/dist/src/web/hooks/use-request-modal.js +9 -0
  54. package/dist/src/web/hooks/use-request-modal.js.map +1 -0
  55. package/dist/src/web/hooks/use-request-modal.test.d.ts +1 -0
  56. package/dist/src/web/hooks/use-request-modal.test.js +24 -0
  57. package/dist/src/web/hooks/use-request-modal.test.js.map +1 -0
  58. package/dist/src/web/hooks/use-send-follow-up-message.d.ts +1 -0
  59. package/dist/src/web/hooks/use-send-follow-up-message.js +11 -0
  60. package/dist/src/web/hooks/use-send-follow-up-message.js.map +1 -0
  61. package/dist/src/web/hooks/use-theme.d.ts +1 -0
  62. package/dist/src/web/hooks/use-theme.js +5 -0
  63. package/dist/src/web/hooks/use-theme.js.map +1 -0
  64. package/dist/src/web/hooks/use-theme.test.d.ts +1 -0
  65. package/dist/src/web/hooks/use-theme.test.js +26 -0
  66. package/dist/src/web/hooks/use-theme.test.js.map +1 -0
  67. package/dist/src/web/hooks/use-tool-info.d.ts +25 -0
  68. package/dist/src/web/hooks/use-tool-info.js +22 -0
  69. package/dist/src/web/hooks/use-tool-info.js.map +1 -0
  70. package/dist/src/web/hooks/use-tool-info.test-d.d.ts +1 -0
  71. package/dist/src/web/hooks/use-tool-info.test-d.js +74 -0
  72. package/dist/src/web/hooks/use-tool-info.test-d.js.map +1 -0
  73. package/dist/src/web/hooks/use-tool-info.test.d.ts +1 -0
  74. package/dist/src/web/hooks/use-tool-info.test.js +59 -0
  75. package/dist/src/web/hooks/use-tool-info.test.js.map +1 -0
  76. package/dist/src/web/hooks/use-tool-output.d.ts +4 -0
  77. package/dist/src/web/hooks/use-tool-output.js +9 -0
  78. package/dist/src/web/hooks/use-tool-output.js.map +1 -0
  79. package/dist/src/web/hooks/use-tool-response-metadata.d.ts +4 -0
  80. package/dist/src/web/hooks/use-tool-response-metadata.js +8 -0
  81. package/dist/src/web/hooks/use-tool-response-metadata.js.map +1 -0
  82. package/dist/src/web/hooks/use-user-agent.d.ts +1 -0
  83. package/dist/src/web/hooks/use-user-agent.js +5 -0
  84. package/dist/src/web/hooks/use-user-agent.js.map +1 -0
  85. package/dist/src/web/hooks/use-user-agent.test.d.ts +1 -0
  86. package/dist/src/web/hooks/use-user-agent.test.js +31 -0
  87. package/dist/src/web/hooks/use-user-agent.test.js.map +1 -0
  88. package/dist/src/web/hooks/use-widget-state.d.ts +4 -0
  89. package/dist/src/web/hooks/use-widget-state.js +30 -0
  90. package/dist/src/web/hooks/use-widget-state.js.map +1 -0
  91. package/dist/src/web/hooks/use-widget-state.test.d.ts +1 -0
  92. package/dist/src/web/hooks/use-widget-state.test.js +60 -0
  93. package/dist/src/web/hooks/use-widget-state.test.js.map +1 -0
  94. package/dist/src/web/index.d.ts +2 -4
  95. package/dist/src/web/index.js +2 -4
  96. package/dist/src/web/index.js.map +1 -1
  97. package/dist/src/web/mount-widget.js +5 -0
  98. package/dist/src/web/mount-widget.js.map +1 -1
  99. package/dist/src/web/plugin.js +2 -4
  100. package/dist/src/web/plugin.js.map +1 -1
  101. package/dist/src/web/proxy.d.ts +1 -0
  102. package/dist/src/web/proxy.js +48 -0
  103. package/dist/src/web/proxy.js.map +1 -0
  104. package/dist/src/web/typed-hooks.d.ts +61 -0
  105. package/dist/src/web/typed-hooks.js +61 -0
  106. package/dist/src/web/typed-hooks.js.map +1 -0
  107. package/dist/src/web/typed-hooks.test-d.d.ts +1 -0
  108. package/dist/src/web/typed-hooks.test-d.js +72 -0
  109. package/dist/src/web/typed-hooks.test-d.js.map +1 -0
  110. package/dist/src/web/typed-hooks.test.d.ts +1 -0
  111. package/dist/src/web/typed-hooks.test.js +10 -0
  112. package/dist/src/web/typed-hooks.test.js.map +1 -0
  113. package/dist/src/web/types.d.ts +30 -14
  114. package/dist/src/web/types.js.map +1 -1
  115. package/dist/vitest.config.js +0 -1
  116. package/dist/vitest.config.js.map +1 -1
  117. package/package.json +4 -2
  118. package/dist/src/test/setup.js +0 -9
  119. package/dist/src/test/setup.js.map +0 -1
  120. package/dist/src/web/use-call-tool.d.ts +0 -54
  121. package/dist/src/web/use-call-tool.js.map +0 -1
  122. package/dist/src/web/use-call-tool.test.js +0 -66
  123. package/dist/src/web/use-call-tool.test.js.map +0 -1
  124. package/dist/src/web/use-openai-global.js.map +0 -1
  125. package/dist/src/web/use-tool-output.d.ts +0 -3
  126. package/dist/src/web/use-tool-output.js +0 -5
  127. package/dist/src/web/use-tool-output.js.map +0 -1
  128. package/dist/src/web/use-tool-response-metadata.d.ts +0 -3
  129. package/dist/src/web/use-tool-response-metadata.js +0 -5
  130. package/dist/src/web/use-tool-response-metadata.js.map +0 -1
  131. /package/dist/src/web/{use-call-tool.test.d.ts → hooks/use-call-tool.test.d.ts} +0 -0
  132. /package/dist/src/{test/setup.d.ts → web/hooks/use-display-mode.test.d.ts} +0 -0
package/README.md CHANGED
@@ -97,6 +97,81 @@ export default defineConfig({
97
97
  });
98
98
  ```
99
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
+ _Server setup (server/src/index.ts)_
105
+
106
+ ```ts
107
+ import { McpServer } from "skybridge/server";
108
+ import { z } from "zod";
109
+
110
+ const server = new McpServer({ name: "my-app", version: "1.0" }, {})
111
+ .widget("search-voyage", {}, {
112
+ description: "Search for trips",
113
+ inputSchema: {
114
+ destination: z.string(),
115
+ departureDate: z.string().optional(),
116
+ },
117
+ outputSchema: {
118
+ results: z.array(z.object({ id: z.string(), name: z.string() })),
119
+ },
120
+ }, async ({ destination }) => {
121
+ // Your tool logic here...
122
+ return { content: [{ type: "text", text: `Found trips to ${destination}` }] };
123
+ })
124
+ .widget("get-details", {}, {
125
+ inputSchema: { tripId: z.string() },
126
+ }, async ({ tripId }) => {
127
+ return { content: [{ type: "text", text: `Details for ${tripId}` }] };
128
+ });
129
+
130
+ // Export the server type for the client
131
+ export type AppType = typeof server;
132
+ ```
133
+
134
+ _One-time setup (web/src/skybridge.ts)_
135
+
136
+ Create typed hooks once and export them for use across your app:
137
+
138
+ ```ts
139
+ import type { AppType } from "../server"; // type-only import
140
+ import { createTypedHooks } from "skybridge/web";
141
+
142
+ export const { useCallTool, useToolInfo } = createTypedHooks<AppType>();
143
+ ```
144
+
145
+ _Usage in widgets (web/src/widgets/search.tsx)_
146
+
147
+ ```tsx
148
+ import { useCallTool, useToolInfo } from "../skybridge"; // import typed hooks
149
+
150
+ export function SearchWidget() {
151
+ const { callTool, data, isPending } = useCallTool("search-voyage");
152
+ // ^ autocomplete for tool names
153
+ const toolInfo = useToolInfo<"search-voyage">();
154
+ // ^ autocomplete for widget names
155
+
156
+ const handleSearch = () => {
157
+ callTool({ destination: "Spain" });
158
+ // ^ autocomplete for input fields
159
+ };
160
+
161
+ return (
162
+ <div>
163
+ <button onClick={handleSearch} disabled={isPending}>
164
+ Search
165
+ </button>
166
+ {toolInfo.isSuccess && (
167
+ <div>Found {toolInfo.output.totalCount} results</div>
168
+ // ^ typed output
169
+ )}
170
+ </div>
171
+ );
172
+ }
173
+ ```
174
+
100
175
  **Hooks**
101
176
 
102
177
  The `skybridge/web` package comes with a set of hooks to help you build your widgets :
@@ -104,7 +179,9 @@ The `skybridge/web` package comes with a set of hooks to help you build your wid
104
179
  - `useOpenAiGlobal`: A generic hook to get any global data from the OpenAI iFrame skybridge runtime (in `window.openai`).
105
180
  - `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
181
  - `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.
182
+ - `useToolInfo`: A hook to get the tool input, output, and response metadata with type inference. Provides a discriminated union based on status (pending/success).
107
183
  - `useCallTool`: A @tanstack/react-query inspired hook to send make additional tool calls inside a widget.
184
+ - `createTypedHooks`: A factory that creates typed versions of `useCallTool` and `useToolInfo` with full type inference from your server type.
108
185
 
109
186
  _useOpenAiGlobal_
110
187
 
@@ -130,6 +207,51 @@ import { useToolResponseMetadata } from "skybridge/web";
130
207
  const toolResponseMetadata = useToolResponseMetadata();
131
208
  ```
132
209
 
210
+ _useToolInfo_
211
+
212
+ ```ts
213
+ import { useToolInfo } from "skybridge/web";
214
+
215
+ const toolInfo = useToolInfo<{
216
+ input: { query: string };
217
+ output: { results: string[] };
218
+ responseMetadata: { id: number };
219
+ }>();
220
+
221
+ // toolInfo.input is typed based on the input type
222
+ // toolInfo.output is typed based on the output type (undefined when pending)
223
+ // toolInfo.status narrows correctly: "pending" | "success"
224
+
225
+ if (toolInfo.isPending) {
226
+ // toolInfo.output is undefined here
227
+ console.log(toolInfo.input.query);
228
+ }
229
+
230
+ if (toolInfo.isSuccess) {
231
+ // toolInfo.output is typed here
232
+ console.log(toolInfo.output.results);
233
+ }
234
+ ```
235
+
236
+ _useToolInfo_ with typed hooks (recommended)
237
+
238
+ ```tsx
239
+ import { useToolInfo } from "../skybridge"; // import typed hooks
240
+
241
+ export function SearchWidget() {
242
+ const toolInfo = useToolInfo<"search-voyage">();
243
+ // ^ autocomplete for widget names
244
+ // toolInfo.input is typed as { destination: string; departureDate?: string; ... }
245
+ // toolInfo.output is typed as { results: Array<...>; totalCount: number; } | undefined
246
+
247
+ if (toolInfo.isSuccess) {
248
+ return <div>Found {toolInfo.output.totalCount} results</div>;
249
+ }
250
+
251
+ return <div>Searching for {toolInfo.input.destination}...</div>;
252
+ }
253
+ ```
254
+
133
255
  _useCallTool_ in synchronous mode
134
256
 
135
257
  ```ts
@@ -1,2 +1,4 @@
1
1
  export { McpServer } from "./server.js";
2
2
  export { widgetsDevServer } from "./widgetsDevServer.js";
3
+ export type { WidgetDef } from "./server.js";
4
+ export type { InferWidgets, AnyWidgetRegistry, WidgetNames, WidgetInput, WidgetOutput, } from "./inferUtilityTypes.js";
@@ -0,0 +1,33 @@
1
+ import type { McpServer, WidgetDef } from "./server.js";
2
+ /** Any widget registry shape */
3
+ export type AnyWidgetRegistry = Record<string, WidgetDef>;
4
+ /**
5
+ * Extract the widget registry type from an McpServer instance.
6
+ *
7
+ * @example
8
+ * ```ts
9
+ * type MyWidgets = InferWidgets<MyServer>;
10
+ * // { "search": WidgetDef<...>, "details": WidgetDef<...> }
11
+ * ```
12
+ */
13
+ export type InferWidgets<T> = T extends McpServer<infer W extends AnyWidgetRegistry> ? W : T extends McpServer<any> ? never : "Error: T must be an McpServer instance";
14
+ /** Get a union of all widget names from an McpServer instance */
15
+ export type WidgetNames<T> = keyof InferWidgets<T> & string;
16
+ /**
17
+ * Get the input type for a specific widget.
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * type SearchInput = WidgetInput<MyServer, "search">;
22
+ * ```
23
+ */
24
+ export type WidgetInput<T, K extends WidgetNames<T>> = InferWidgets<T> extends Record<string, WidgetDef> ? K extends keyof InferWidgets<T> ? InferWidgets<T>[K]["input"] : never : never;
25
+ /**
26
+ * Get the output type for a specific widget.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * type SearchOutput = WidgetOutput<MyServer, "search">;
31
+ * ```
32
+ */
33
+ export type WidgetOutput<T, K extends WidgetNames<T>> = InferWidgets<T> extends Record<string, WidgetDef> ? K extends keyof InferWidgets<T> ? InferWidgets<T>[K]["output"] : never : never;
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=inferUtilityTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inferUtilityTypes.js","sourceRoot":"","sources":["../../../src/server/inferUtilityTypes.ts"],"names":[],"mappings":""}
@@ -1,12 +1,19 @@
1
1
  import { McpServer as McpServerBase, type ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import type { Resource } from "@modelcontextprotocol/sdk/types.js";
3
- import type { ZodRawShape } from "zod";
3
+ import type { ZodRawShape, ZodObject, infer as Infer } from "zod";
4
+ export type WidgetDef<TInput = unknown, TOutput = unknown> = {
5
+ input: TInput;
6
+ output: TOutput;
7
+ };
4
8
  type McpServerOriginalResourceConfig = Omit<Resource, "uri" | "name" | "mimeType">;
5
- type McpServerOriginalToolConfig = Omit<Parameters<McpServer["registerTool"]>[1], "inputSchema" | "outputSchema">;
6
- export declare class McpServer extends McpServerBase {
7
- widget<InputArgs extends ZodRawShape, OutputArgs extends ZodRawShape>(name: string, resourceConfig: McpServerOriginalResourceConfig, toolConfig: McpServerOriginalToolConfig & {
8
- inputSchema?: InputArgs;
9
- outputSchema?: OutputArgs;
10
- }, toolCallback: ToolCallback<InputArgs>): void;
9
+ type McpServerOriginalToolConfig = Omit<Parameters<McpServerBase["registerTool"]>[1], "inputSchema" | "outputSchema">;
10
+ export declare class McpServer<TWidgets extends Record<string, WidgetDef> = {}> extends McpServerBase {
11
+ widget<TName extends string, TInput extends ZodRawShape, TOutput extends ZodRawShape = {}>(name: TName, resourceConfig: McpServerOriginalResourceConfig, toolConfig: McpServerOriginalToolConfig & {
12
+ inputSchema?: TInput;
13
+ outputSchema?: TOutput;
14
+ }, toolCallback: ToolCallback<TInput>): McpServer<TWidgets & {
15
+ [K in TName]: WidgetDef<Infer<ZodObject<TInput>>, Infer<ZodObject<TOutput>>>;
16
+ }>;
17
+ private lookupDistFile;
11
18
  }
12
19
  export {};
@@ -1,9 +1,13 @@
1
1
  import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mcp.js";
2
2
  import { templateHelper } from "./templateHelper.js";
3
+ import { readFileSync } from "node:fs";
4
+ import path from "node:path";
3
5
  export class McpServer extends McpServerBase {
4
6
  widget(name, resourceConfig, toolConfig, toolCallback) {
5
7
  const uri = `ui://widgets/${name}.html`;
6
- const resourceMetadata = { ...(resourceConfig._meta ?? {}) };
8
+ const resourceMetadata = {
9
+ ...(resourceConfig._meta ?? {}),
10
+ };
7
11
  if (toolConfig.description !== undefined) {
8
12
  resourceMetadata["openai/widgetDescription"] = toolConfig.description;
9
13
  }
@@ -15,13 +19,16 @@ export class McpServer extends McpServerBase {
15
19
  ? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ??
16
20
  extra?.requestInfo?.headers?.host}`
17
21
  : `http://localhost:3000`;
18
- const templateData = {
19
- serverUrl,
20
- widgetName: name,
21
- };
22
22
  const html = process.env.NODE_ENV === "production"
23
- ? templateHelper.renderProduction(templateData)
24
- : templateHelper.renderDevelopment(templateData);
23
+ ? templateHelper.renderProduction({
24
+ serverUrl,
25
+ widgetFile: this.lookupDistFile(`src/widgets/${name}.tsx`),
26
+ styleFile: this.lookupDistFile("style.css"),
27
+ })
28
+ : templateHelper.renderDevelopment({
29
+ serverUrl,
30
+ widgetName: name,
31
+ });
25
32
  return {
26
33
  contents: [
27
34
  {
@@ -35,11 +42,17 @@ export class McpServer extends McpServerBase {
35
42
  const toolMeta = {
36
43
  ...toolConfig._meta,
37
44
  "openai/outputTemplate": uri,
45
+ "ui/resourceUri": uri,
38
46
  };
39
47
  this.registerTool(name, {
40
48
  ...toolConfig,
41
49
  _meta: toolMeta,
42
50
  }, toolCallback);
51
+ return this;
52
+ }
53
+ lookupDistFile(key) {
54
+ const manifest = JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
55
+ return manifest[key]?.file;
43
56
  }
44
57
  }
45
58
  //# sourceMappingURL=server.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"server.js","sourceRoot":"","sources":["../../../src/server/server.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,IAAI,aAAa,GAE3B,MAAM,yCAAyC,CAAC;AAGjD,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AA4BrD,MAAM,OAAO,SAAU,SAAQ,aAAa;IAC1C,MAAM,CACJ,IAAY,EACZ,cAA+C,EAC/C,UAGC,EACD,YAAqC;QAErC,MAAM,GAAG,GAAG,gBAAgB,IAAI,OAAO,CAAC;QACxC,MAAM,gBAAgB,GAAiB,EAAE,GAAG,CAAC,cAAc,CAAC,KAAK,IAAI,EAAE,CAAC,EAAE,CAAC;QAC3E,IAAI,UAAU,CAAC,WAAW,KAAK,SAAS,EAAE,CAAC;YACzC,gBAAgB,CAAC,0BAA0B,CAAC,GAAG,UAAU,CAAC,WAAW,CAAC;QACxE,CAAC;QAED,IAAI,CAAC,QAAQ,CACX,IAAI,EACJ,GAAG,EACH;YACE,GAAG,cAAc;YACjB,KAAK,EAAE,gBAAgB;SACxB,EACD,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE;YACpB,MAAM,SAAS,GACb,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,YAAY;gBACnC,CAAC,CAAC,WACE,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,CAAC,kBAAkB,CAAC;oBACjD,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,IAC/B,EAAE;gBACJ,CAAC,CAAC,uBAAuB,CAAC;YAE9B,MAAM,YAAY,GAA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,GAAG,IAAI,CAAC,KAAK,CACzB,YAAY,CACV,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,EAAE,eAAe,CAAC,EACpE,OAAO,CACR,CACF,CAAC;QAEF,OAAO,QAAQ,CAAC,GAAG,CAAC,EAAE,IAAI,CAAC;IAC7B,CAAC;CACF"}
@@ -1,14 +1,15 @@
1
- type TemplateData = {
2
- serverUrl: string;
3
- widgetName: string;
4
- };
5
1
  declare class TemplateHelper {
6
2
  private templateCache;
7
3
  private loadTemplate;
8
- renderProduction(data: TemplateData): string;
9
- renderDevelopment(data: TemplateData): string;
10
- renderViteClient(data: TemplateData): string;
11
- injectViteClient(html: string, data: TemplateData): string;
4
+ renderProduction(data: {
5
+ serverUrl: string;
6
+ widgetFile: string;
7
+ styleFile: string;
8
+ }): string;
9
+ renderDevelopment(data: {
10
+ serverUrl: string;
11
+ widgetName: string;
12
+ }): string;
12
13
  }
13
14
  export declare const templateHelper: TemplateHelper;
14
15
  export {};
@@ -24,14 +24,6 @@ class TemplateHelper {
24
24
  const template = this.loadTemplate("development");
25
25
  return template(data);
26
26
  }
27
- renderViteClient(data) {
28
- const template = this.loadTemplate("vite-client");
29
- return template(data);
30
- }
31
- injectViteClient(html, data) {
32
- const viteClientScript = this.renderViteClient(data);
33
- return viteClientScript + html;
34
- }
35
27
  }
36
28
  export const templateHelper = new TemplateHelper();
37
29
  //# sourceMappingURL=templateHelper.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"templateHelper.js","sourceRoot":"","sources":["../../../src/server/templateHelper.ts"],"names":[],"mappings":"AAAA,OAAO,UAAU,MAAM,YAAY,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,MAAM,UAAU,G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AI,CAAC,CAAC;IACxB,CAAC;IAED,iBAAiB,CAAC,IAA+C;QAC/D,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,aAAa,CAAC,CAAC;QAClD,OAAO,QAAQ,CAAC,IAAI,CAAC,CAAC;IACxB,CAAC;CACF;AAED,MAAM,CAAC,MAAM,cAAc,GAAG,IAAI,cAAc,EAAE,CAAC"}
@@ -1,3 +1,4 @@
1
+ <base href="{{serverUrl}}" />
1
2
  <script type="module">
2
3
  import { injectIntoGlobalHook } from "{{serverUrl}}/@react-refresh";
3
4
  injectIntoGlobalHook(window); window.$RefreshReg$ = () => {};
@@ -1,5 +1,6 @@
1
+ <base href="{{serverUrl}}" />
1
2
  <div id="root"></div>
2
3
  <script type="module">
3
- import('{{serverUrl}}/assets/{{widgetName}}.js');
4
+ import('{{serverUrl}}/assets/{{widgetFile}}');
4
5
  </script>
5
- <link rel="stylesheet" crossorigin href="{{serverUrl}}/assets/style.css" />
6
+ <link rel="stylesheet" crossorigin href="{{serverUrl}}/assets/{{styleFile}}" />
@@ -1,5 +1,5 @@
1
1
  import { vi } from "vitest";
2
- import { McpServer, McpServer as McpServerBase } from "../server/server.js";
2
+ import { McpServer } from "../server/server.js";
3
3
  /**
4
4
  * Creates a real McpServer instance for testing
5
5
  */
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/test/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAqB,MAAM,QAAQ,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE5E;;GAEG;AACH,MAAM,UAAU,mBAAmB;IAKjC,mCAAmC;IACnC,MAAM,MAAM,GAAG,IAAI,SAAS,CAC1B;QACE,IAAI,EAAE,kBAAkB;QACxB,OAAO,EAAE,OAAO;KACjB,EACD,EAAE,YAAY,EAAE,EAAE,EAAE,CACrB,CAAC;IAEF,6CAA6C;IAC7C,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AACH,MAAM,UAAU,eAAe,CAAC,IAAY;IAC1C,OAAO;QACL,WAAW,EAAE;YACX,OAAO,EAAE,EAAE,IAAI,EAAE;SAClB;KACF,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CAAC,GAA2B;IACpD,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY;IAC1B,OAAO,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC;AAC9B,CAAC"}
@@ -1,10 +1,31 @@
1
- import { describe, it, expect, vi, beforeEach, afterEach, } from "vitest";
1
+ import * as fs from "node:fs";
2
+ import { afterEach, beforeEach, describe, expect, it, vi, } from "vitest";
2
3
  import { McpServer } from "../server/server.js";
3
- import { createMockMcpServer, createMockExtra, setTestEnv, resetTestEnv, } from "./utils.js";
4
+ import { createMockExtra, createMockMcpServer, resetTestEnv, setTestEnv, } from "./utils.js";
5
+ const mockManifest = {
6
+ "src/widgets/my-widget.tsx": { file: "my-widget.js" },
7
+ "style.css": { file: "style.css" },
8
+ };
9
+ vi.mock("node:fs", async () => {
10
+ const actual = await vi.importActual("node:fs");
11
+ const readFileSync = vi.fn((path, ...args) => {
12
+ if (typeof path === "string" && path.includes("manifest.json")) {
13
+ return JSON.stringify(mockManifest);
14
+ }
15
+ return actual.readFileSync(path, ...args);
16
+ });
17
+ return {
18
+ readFileSync,
19
+ default: {
20
+ readFileSync,
21
+ },
22
+ };
23
+ });
4
24
  describe("McpServer.widget", () => {
5
25
  let server;
6
26
  let mockResource;
7
27
  let mockRegisterTool;
28
+ let readFileSyncSpy = null;
8
29
  beforeEach(() => {
9
30
  ({ server, mockResource, mockRegisterTool } = createMockMcpServer());
10
31
  });
@@ -1 +1 @@
1
- {"version":3,"file":"widget.test.js","sourceRoot":"","sources":["../../../src/test/widget.test.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,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QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CAC5C,SAAS,GAAG,gBAAgB,CAC7B,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,GAAG,CAAC,SAAS,CAAC,SAAS,GAAG,cAAc,CAAC,CAAC;QAC3E,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,CACxC,SAAS,GAAG,sBAAsB,CACnC,CAAC;QACF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,IAAI,CAAC,CAAC,SAAS,CAAC,SAAS,GAAG,mBAAmB,CAAC,CAAC;IAC9E,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
@@ -0,0 +1,14 @@
1
+ export { useCallTool } from "./use-call-tool.js";
2
+ export { useDisplayMode } from "./use-display-mode.js";
3
+ export { useFiles } from "./use-files.js";
4
+ export { useLocale } from "./use-locale.js";
5
+ export { useOpenAiGlobal } from "./use-openai-global.js";
6
+ export { useOpenExternal } from "./use-open-external.js";
7
+ export { useRequestModal } from "./use-request-modal.js";
8
+ export { useSendFollowUpMessage } from "./use-send-follow-up-message.js";
9
+ export { useTheme } from "./use-theme.js";
10
+ export { useToolInfo } from "./use-tool-info.js";
11
+ export { useToolOutput } from "./use-tool-output.js";
12
+ export { useToolResponseMetadata } from "./use-tool-response-metadata.js";
13
+ export { useUserAgent } from "./use-user-agent.js";
14
+ export { useWidgetState } from "./use-widget-state.js";
@@ -0,0 +1,15 @@
1
+ export { useCallTool } from "./use-call-tool.js";
2
+ export { useDisplayMode } from "./use-display-mode.js";
3
+ export { useFiles } from "./use-files.js";
4
+ export { useLocale } from "./use-locale.js";
5
+ export { useOpenAiGlobal } from "./use-openai-global.js";
6
+ export { useOpenExternal } from "./use-open-external.js";
7
+ export { useRequestModal } from "./use-request-modal.js";
8
+ export { useSendFollowUpMessage } from "./use-send-follow-up-message.js";
9
+ export { useTheme } from "./use-theme.js";
10
+ export { useToolInfo } from "./use-tool-info.js";
11
+ export { useToolOutput } from "./use-tool-output.js";
12
+ export { useToolResponseMetadata } from "./use-tool-response-metadata.js";
13
+ export { useUserAgent } from "./use-user-agent.js";
14
+ export { useWidgetState } from "./use-widget-state.js";
15
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/web/hooks/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,sBAAsB,EAAE,MAAM,iCAAiC,CAAC;AACzE,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AACjD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,uBAAuB,EAAE,MAAM,iCAAiC,CAAC;AAC1E,OAAO,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AACnD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC"}
@@ -0,0 +1,62 @@
1
+ import type { CallToolArgs, CallToolResponse } from "../types.js";
2
+ type SideEffects<ToolArgs, ToolResponse> = {
3
+ onSuccess?: (data: ToolResponse, toolArgs: ToolArgs) => void;
4
+ onError?: (error: unknown, toolArgs: ToolArgs) => void;
5
+ onSettled?: (data: ToolResponse | undefined, error: unknown | undefined, toolArgs: ToolArgs) => void;
6
+ };
7
+ type CallToolAsyncFn<ToolArgs, ToolResponse> = ToolArgs extends null ? () => Promise<ToolResponse> : (toolArgs: ToolArgs) => Promise<ToolResponse>;
8
+ type ToolResponseSignature = Pick<CallToolResponse, "structuredContent" | "meta">;
9
+ export declare const useCallTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends Partial<ToolResponseSignature> = {}>(name: string) => {
10
+ callTool: {
11
+ (sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
12
+ (toolArgs: ToolArgs, sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
13
+ };
14
+ callToolAsync: CallToolAsyncFn<ToolArgs, CallToolResponse & ToolResponse>;
15
+ status: "idle";
16
+ isIdle: true;
17
+ isPending: false;
18
+ isSuccess: false;
19
+ isError: false;
20
+ data: undefined;
21
+ error: undefined;
22
+ } | {
23
+ callTool: {
24
+ (sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
25
+ (toolArgs: ToolArgs, sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
26
+ };
27
+ callToolAsync: CallToolAsyncFn<ToolArgs, CallToolResponse & ToolResponse>;
28
+ status: "pending";
29
+ isIdle: false;
30
+ isPending: true;
31
+ isSuccess: false;
32
+ isError: false;
33
+ data: undefined;
34
+ error: undefined;
35
+ } | {
36
+ callTool: {
37
+ (sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
38
+ (toolArgs: ToolArgs, sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
39
+ };
40
+ callToolAsync: CallToolAsyncFn<ToolArgs, CallToolResponse & ToolResponse>;
41
+ status: "error";
42
+ isIdle: false;
43
+ isPending: false;
44
+ isSuccess: false;
45
+ isError: true;
46
+ data: undefined;
47
+ error: unknown;
48
+ } | {
49
+ callTool: {
50
+ (sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
51
+ (toolArgs: ToolArgs, sideEffects?: SideEffects<ToolArgs, CallToolResponse & ToolResponse>): void;
52
+ };
53
+ callToolAsync: CallToolAsyncFn<ToolArgs, CallToolResponse & ToolResponse>;
54
+ status: "success";
55
+ isIdle: false;
56
+ isPending: false;
57
+ isSuccess: true;
58
+ isError: false;
59
+ data: CallToolResponse & ToolResponse;
60
+ error: undefined;
61
+ };
62
+ export {};
@@ -1,7 +1,7 @@
1
1
  import { useState } from "react";
2
2
  export const useCallTool = (name) => {
3
3
  const [{ status, data, error }, setCallToolState] = useState({ status: "idle", data: undefined, error: undefined });
4
- const callToolAsync = async (toolArgs) => {
4
+ const execute = async (toolArgs) => {
5
5
  setCallToolState({ status: "pending", data: undefined, error: undefined });
6
6
  try {
7
7
  const data = await window.openai.callTool(name, toolArgs);
@@ -13,19 +13,43 @@ export const useCallTool = (name) => {
13
13
  throw error;
14
14
  }
15
15
  };
16
- const callTool = (toolArgs, sideEffects) => {
17
- callToolAsync(toolArgs)
16
+ const callToolAsync = (async (toolArgs) => {
17
+ if (toolArgs === undefined) {
18
+ return execute(null);
19
+ }
20
+ return execute(toolArgs);
21
+ });
22
+ function callTool(firstArg, sideEffects) {
23
+ let toolArgs;
24
+ if (firstArg &&
25
+ typeof firstArg === "object" &&
26
+ ("onSuccess" in firstArg ||
27
+ "onError" in firstArg ||
28
+ "onSettled" in firstArg)) {
29
+ toolArgs = null; // no toolArgs provided
30
+ sideEffects = firstArg;
31
+ }
32
+ else {
33
+ toolArgs = (firstArg === undefined ? null : firstArg);
34
+ }
35
+ execute(toolArgs)
18
36
  .then((data) => {
19
37
  if (sideEffects?.onSuccess) {
20
38
  sideEffects.onSuccess(data, toolArgs);
21
39
  }
40
+ if (sideEffects?.onSettled) {
41
+ sideEffects.onSettled(data, undefined, toolArgs);
42
+ }
22
43
  })
23
44
  .catch((error) => {
24
45
  if (sideEffects?.onError) {
25
46
  sideEffects.onError(error, toolArgs);
26
47
  }
48
+ if (sideEffects?.onSettled) {
49
+ sideEffects.onSettled(undefined, error, toolArgs);
50
+ }
27
51
  });
28
- };
52
+ }
29
53
  const callToolState = {
30
54
  status,
31
55
  data,
@@ -0,0 +1 @@
1
+ {"version":3,"file":"use-call-tool.js","sourceRoot":"","sources":["../../../../src/web/hooks/use-call-tool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAoEjC,MAAM,CAAC,MAAM,WAAW,GAAG,CAIzB,IAAY,EACZ,EAAE;IAGF,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,EAAE,gBAAgB,CAAC,GAAG,QAAQ,CAK1D,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;IAEzD,MAAM,OAAO,GAAG,KAAK,EACnB,QAAkB,EACiB,EAAE;QACrC,gBAAgB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;QAC3E,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,QAAQ,CAGvC,IAAI,EAAE,QAAQ,CAAC,CAAC;YAClB,gBAAgB,CAAC,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC,CAAC;YAEhE,OAAO,IAAI,CAAC;QACd,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,gBAAgB,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE,CAAC,CAAC;YAC9D,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC;IAEF,MAAM,aAAa,GAAG,CAAC,KAAK,EAAE,QAAmB,EAAE,EAAE;QACnD,IAAI,QA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