skybridge 0.0.0-dev.e2cf49b → 0.0.0-dev.e341b6a
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -674
- package/bin/run.js +5 -0
- package/dist/server/index.d.ts +4 -0
- package/dist/server/index.js.map +1 -0
- package/dist/server/inferUtilityTypes.d.ts +64 -0
- package/dist/server/inferUtilityTypes.js +2 -0
- package/dist/server/inferUtilityTypes.js.map +1 -0
- package/dist/server/server.d.ts +101 -0
- package/dist/server/server.js +130 -0
- package/dist/server/server.js.map +1 -0
- package/dist/{src/server → server}/templateHelper.d.ts +3 -0
- package/dist/{src/server → server}/templateHelper.js +5 -4
- package/dist/server/templateHelper.js.map +1 -0
- package/dist/server/templates/development.hbs +66 -0
- package/dist/{src/server → server}/templates/production.hbs +1 -0
- package/dist/{src/server → server}/widgetsDevServer.d.ts +2 -2
- package/dist/{src/server → server}/widgetsDevServer.js +13 -5
- package/dist/server/widgetsDevServer.js.map +1 -0
- package/dist/test/utils.d.ts +135 -0
- package/dist/test/utils.js +242 -0
- package/dist/test/utils.js.map +1 -0
- package/dist/test/widget.test.js +250 -0
- package/dist/test/widget.test.js.map +1 -0
- package/dist/web/bridges/adaptors/apps-sdk-adaptor.d.ts +13 -0
- package/dist/web/bridges/adaptors/apps-sdk-adaptor.js +33 -0
- package/dist/web/bridges/adaptors/apps-sdk-adaptor.js.map +1 -0
- package/dist/web/bridges/adaptors/mcp-app-adaptor.d.ts +16 -0
- package/dist/web/bridges/adaptors/mcp-app-adaptor.js +115 -0
- package/dist/web/bridges/adaptors/mcp-app-adaptor.js.map +1 -0
- package/dist/web/bridges/apps-sdk-bridge.d.ts +10 -0
- package/dist/web/bridges/apps-sdk-bridge.js +46 -0
- package/dist/web/bridges/apps-sdk-bridge.js.map +1 -0
- package/dist/web/bridges/hooks/use-adaptor.d.ts +2 -0
- package/dist/web/bridges/hooks/use-adaptor.js +8 -0
- package/dist/web/bridges/hooks/use-adaptor.js.map +1 -0
- package/dist/web/bridges/hooks/use-apps-sdk-bridge.d.ts +2 -0
- package/dist/web/bridges/hooks/use-apps-sdk-bridge.js +7 -0
- package/dist/web/bridges/hooks/use-apps-sdk-bridge.js.map +1 -0
- package/dist/web/bridges/hooks/use-bridge.d.ts +2 -0
- package/dist/web/bridges/hooks/use-bridge.js +8 -0
- package/dist/web/bridges/hooks/use-bridge.js.map +1 -0
- package/dist/web/bridges/hooks/use-mcp-app-bridge.d.ts +5 -0
- package/dist/web/bridges/hooks/use-mcp-app-bridge.js +7 -0
- package/dist/web/bridges/hooks/use-mcp-app-bridge.js.map +1 -0
- package/dist/web/bridges/hooks/use-mcp-app-bridge.test.js +41 -0
- package/dist/web/bridges/hooks/use-mcp-app-bridge.test.js.map +1 -0
- package/dist/web/bridges/index.d.ts +4 -0
- package/dist/web/bridges/index.js +5 -0
- package/dist/web/bridges/index.js.map +1 -0
- package/dist/web/bridges/mcp-app-bridge.d.ts +38 -0
- package/dist/web/bridges/mcp-app-bridge.js +162 -0
- package/dist/web/bridges/mcp-app-bridge.js.map +1 -0
- package/dist/web/bridges/types.d.ts +57 -0
- package/dist/web/bridges/types.js +2 -0
- package/dist/web/bridges/types.js.map +1 -0
- package/dist/web/create-store.d.ts +3 -0
- package/dist/web/create-store.js +25 -0
- package/dist/web/create-store.js.map +1 -0
- package/dist/web/create-store.test.js +70 -0
- package/dist/web/create-store.test.js.map +1 -0
- package/dist/web/data-llm.d.ts +14 -0
- package/dist/web/data-llm.js +70 -0
- package/dist/web/data-llm.js.map +1 -0
- package/dist/web/data-llm.test.js +76 -0
- package/dist/web/data-llm.test.js.map +1 -0
- package/dist/web/generate-helpers.d.ts +115 -0
- package/dist/web/generate-helpers.js +111 -0
- package/dist/web/generate-helpers.js.map +1 -0
- package/dist/web/generate-helpers.test-d.js +209 -0
- package/dist/web/generate-helpers.test-d.js.map +1 -0
- package/dist/web/generate-helpers.test.js +17 -0
- package/dist/web/generate-helpers.test.js.map +1 -0
- package/dist/web/helpers/state.d.ts +7 -0
- package/dist/web/helpers/state.js +40 -0
- package/dist/web/helpers/state.js.map +1 -0
- package/dist/web/helpers/state.test.js +53 -0
- package/dist/web/helpers/state.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/index.d.ts +4 -6
- package/dist/{src/web → web}/hooks/index.js +4 -6
- package/dist/web/hooks/index.js.map +1 -0
- package/dist/web/hooks/test/utils.d.ts +10 -0
- package/dist/web/hooks/test/utils.js +40 -0
- package/dist/web/hooks/test/utils.js.map +1 -0
- package/dist/web/hooks/use-call-tool.d.ts +100 -0
- package/dist/web/hooks/use-call-tool.js +68 -0
- package/dist/web/hooks/use-call-tool.js.map +1 -0
- package/dist/web/hooks/use-call-tool.test-d.js +104 -0
- package/dist/web/hooks/use-call-tool.test-d.js.map +1 -0
- package/dist/web/hooks/use-call-tool.test.js +190 -0
- package/dist/web/hooks/use-call-tool.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-display-mode.d.ts +1 -1
- package/dist/web/hooks/use-display-mode.js +10 -0
- package/dist/web/hooks/use-display-mode.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-display-mode.test.js +3 -2
- package/dist/web/hooks/use-display-mode.test.js.map +1 -0
- package/dist/web/hooks/use-files.d.ts +10 -0
- package/dist/web/hooks/use-files.js +7 -0
- package/dist/web/hooks/use-files.js.map +1 -0
- package/dist/web/hooks/use-files.test.js +29 -0
- package/dist/web/hooks/use-files.test.js.map +1 -0
- package/dist/web/hooks/use-layout.d.ts +22 -0
- package/dist/web/hooks/use-layout.js +23 -0
- package/dist/web/hooks/use-layout.js.map +1 -0
- package/dist/web/hooks/use-layout.test.d.ts +1 -0
- package/dist/web/hooks/use-layout.test.js +95 -0
- package/dist/web/hooks/use-layout.test.js.map +1 -0
- package/dist/web/hooks/use-open-external.js +8 -0
- package/dist/web/hooks/use-open-external.js.map +1 -0
- package/dist/web/hooks/use-open-external.test.d.ts +1 -0
- package/dist/web/hooks/use-open-external.test.js +50 -0
- package/dist/web/hooks/use-open-external.test.js.map +1 -0
- package/dist/web/hooks/use-openai-global.d.ts +3 -0
- package/dist/web/hooks/use-openai-global.js +6 -0
- package/dist/web/hooks/use-openai-global.js.map +1 -0
- package/dist/web/hooks/use-request-modal.d.ts +9 -0
- package/dist/web/hooks/use-request-modal.js +14 -0
- package/dist/web/hooks/use-request-modal.js.map +1 -0
- package/dist/web/hooks/use-request-modal.test.d.ts +1 -0
- package/dist/web/hooks/use-request-modal.test.js +57 -0
- package/dist/web/hooks/use-request-modal.test.js.map +1 -0
- package/dist/web/hooks/use-send-follow-up-message.js +8 -0
- package/dist/web/hooks/use-send-follow-up-message.js.map +1 -0
- package/dist/web/hooks/use-tool-info.d.ts +36 -0
- package/dist/web/hooks/use-tool-info.js +26 -0
- package/dist/web/hooks/use-tool-info.js.map +1 -0
- package/dist/web/hooks/use-tool-info.test-d.d.ts +1 -0
- package/dist/web/hooks/use-tool-info.test-d.js +109 -0
- package/dist/web/hooks/use-tool-info.test-d.js.map +1 -0
- package/dist/web/hooks/use-tool-info.test.d.ts +1 -0
- package/dist/web/hooks/use-tool-info.test.js +130 -0
- package/dist/web/hooks/use-tool-info.test.js.map +1 -0
- package/dist/web/hooks/use-user.d.ts +18 -0
- package/dist/web/hooks/use-user.js +19 -0
- package/dist/web/hooks/use-user.js.map +1 -0
- package/dist/web/hooks/use-user.test.d.ts +1 -0
- package/dist/web/hooks/use-user.test.js +93 -0
- package/dist/web/hooks/use-user.test.js.map +1 -0
- package/dist/{src/web → web}/hooks/use-widget-state.js +11 -9
- package/dist/web/hooks/use-widget-state.js.map +1 -0
- package/dist/web/hooks/use-widget-state.test.d.ts +1 -0
- package/dist/{src/web → web}/hooks/use-widget-state.test.js +3 -3
- package/dist/web/hooks/use-widget-state.test.js.map +1 -0
- package/dist/web/index.d.ts +8 -0
- package/dist/web/index.js +9 -0
- package/dist/web/index.js.map +1 -0
- package/dist/{src/web → web}/mount-widget.js +5 -0
- package/dist/web/mount-widget.js.map +1 -0
- package/dist/web/plugin/data-llm.test.d.ts +1 -0
- package/dist/web/plugin/data-llm.test.js +81 -0
- package/dist/web/plugin/data-llm.test.js.map +1 -0
- package/dist/web/plugin/plugin.js +39 -0
- package/dist/web/plugin/plugin.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.d.ts +12 -0
- package/dist/web/plugin/transform-data-llm.js +96 -0
- package/dist/web/plugin/transform-data-llm.js.map +1 -0
- package/dist/web/plugin/transform-data-llm.test.d.ts +1 -0
- package/dist/web/plugin/transform-data-llm.test.js +81 -0
- package/dist/web/plugin/transform-data-llm.test.js.map +1 -0
- package/dist/web/proxy.d.ts +1 -0
- package/dist/web/proxy.js +53 -0
- package/dist/web/proxy.js.map +1 -0
- package/dist/{src/web → web}/types.d.ts +68 -29
- package/dist/{src/web → web}/types.js +1 -0
- package/dist/web/types.js.map +1 -0
- package/package.json +53 -28
- package/README.md +0 -198
- package/dist/src/server/index.d.ts +0 -2
- package/dist/src/server/index.js.map +0 -1
- package/dist/src/server/server.d.ts +0 -13
- package/dist/src/server/server.js +0 -54
- package/dist/src/server/server.js.map +0 -1
- package/dist/src/server/templateHelper.js.map +0 -1
- package/dist/src/server/templates/development.hbs +0 -12
- package/dist/src/server/widgetsDevServer.js.map +0 -1
- package/dist/src/test/setup.js +0 -9
- package/dist/src/test/setup.js.map +0 -1
- package/dist/src/test/utils.d.ts +0 -28
- package/dist/src/test/utils.js +0 -43
- package/dist/src/test/utils.js.map +0 -1
- package/dist/src/test/widget.test.js +0 -90
- package/dist/src/test/widget.test.js.map +0 -1
- package/dist/src/web/hooks/index.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.d.ts +0 -62
- package/dist/src/web/hooks/use-call-tool.js +0 -66
- package/dist/src/web/hooks/use-call-tool.js.map +0 -1
- package/dist/src/web/hooks/use-call-tool.test.js +0 -104
- package/dist/src/web/hooks/use-call-tool.test.js.map +0 -1
- package/dist/src/web/hooks/use-display-mode.js +0 -7
- package/dist/src/web/hooks/use-display-mode.js.map +0 -1
- package/dist/src/web/hooks/use-display-mode.test.js.map +0 -1
- package/dist/src/web/hooks/use-locale.d.ts +0 -1
- package/dist/src/web/hooks/use-locale.js +0 -5
- package/dist/src/web/hooks/use-locale.js.map +0 -1
- package/dist/src/web/hooks/use-locale.test.js +0 -21
- package/dist/src/web/hooks/use-locale.test.js.map +0 -1
- package/dist/src/web/hooks/use-open-external.js +0 -6
- package/dist/src/web/hooks/use-open-external.js.map +0 -1
- package/dist/src/web/hooks/use-open-external.test.js +0 -24
- package/dist/src/web/hooks/use-open-external.test.js.map +0 -1
- package/dist/src/web/hooks/use-openai-global.d.ts +0 -2
- package/dist/src/web/hooks/use-openai-global.js +0 -21
- package/dist/src/web/hooks/use-openai-global.js.map +0 -1
- package/dist/src/web/hooks/use-request-modal.d.ts +0 -5
- package/dist/src/web/hooks/use-request-modal.js +0 -9
- package/dist/src/web/hooks/use-request-modal.js.map +0 -1
- package/dist/src/web/hooks/use-request-modal.test.js +0 -24
- package/dist/src/web/hooks/use-request-modal.test.js.map +0 -1
- package/dist/src/web/hooks/use-send-follow-up-message.js +0 -11
- package/dist/src/web/hooks/use-send-follow-up-message.js.map +0 -1
- package/dist/src/web/hooks/use-theme.d.ts +0 -1
- package/dist/src/web/hooks/use-theme.js +0 -5
- package/dist/src/web/hooks/use-theme.js.map +0 -1
- package/dist/src/web/hooks/use-theme.test.js +0 -26
- package/dist/src/web/hooks/use-theme.test.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.d.ts +0 -5
- package/dist/src/web/hooks/use-tool-info.js +0 -9
- package/dist/src/web/hooks/use-tool-info.js.map +0 -1
- package/dist/src/web/hooks/use-tool-info.test.js +0 -38
- package/dist/src/web/hooks/use-tool-info.test.js.map +0 -1
- package/dist/src/web/hooks/use-tool-output.d.ts +0 -4
- package/dist/src/web/hooks/use-tool-output.js +0 -9
- package/dist/src/web/hooks/use-tool-output.js.map +0 -1
- package/dist/src/web/hooks/use-tool-response-metadata.d.ts +0 -4
- package/dist/src/web/hooks/use-tool-response-metadata.js +0 -8
- package/dist/src/web/hooks/use-tool-response-metadata.js.map +0 -1
- package/dist/src/web/hooks/use-user-agent.d.ts +0 -1
- package/dist/src/web/hooks/use-user-agent.js +0 -5
- package/dist/src/web/hooks/use-user-agent.js.map +0 -1
- package/dist/src/web/hooks/use-user-agent.test.js +0 -31
- package/dist/src/web/hooks/use-user-agent.test.js.map +0 -1
- package/dist/src/web/hooks/use-widget-state.js.map +0 -1
- package/dist/src/web/hooks/use-widget-state.test.js.map +0 -1
- package/dist/src/web/index.d.ts +0 -4
- package/dist/src/web/index.js +0 -5
- package/dist/src/web/index.js.map +0 -1
- package/dist/src/web/mount-widget.js.map +0 -1
- package/dist/src/web/plugin.js +0 -28
- package/dist/src/web/plugin.js.map +0 -1
- package/dist/src/web/types.js.map +0 -1
- package/dist/vitest.config.d.ts +0 -2
- package/dist/vitest.config.js +0 -9
- package/dist/vitest.config.js.map +0 -1
- /package/dist/{src/server → server}/index.js +0 -0
- /package/dist/{src/test → test}/widget.test.d.ts +0 -0
- /package/dist/{src/test/setup.d.ts → web/bridges/hooks/use-mcp-app-bridge.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-call-tool.test.d.ts → web/create-store.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-display-mode.test.d.ts → web/data-llm.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-locale.test.d.ts → web/generate-helpers.test-d.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-open-external.test.d.ts → web/generate-helpers.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-request-modal.test.d.ts → web/helpers/state.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-theme.test.d.ts → web/hooks/use-call-tool.test-d.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-tool-info.test.d.ts → web/hooks/use-call-tool.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-user-agent.test.d.ts → web/hooks/use-display-mode.test.d.ts} +0 -0
- /package/dist/{src/web/hooks/use-widget-state.test.d.ts → web/hooks/use-files.test.d.ts} +0 -0
- /package/dist/{src/web → web}/hooks/use-open-external.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-send-follow-up-message.d.ts +0 -0
- /package/dist/{src/web → web}/hooks/use-widget-state.d.ts +0 -0
- /package/dist/{src/web → web}/mount-widget.d.ts +0 -0
- /package/dist/{src/web → web/plugin}/plugin.d.ts +0 -0
|
@@ -0,0 +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,UAAU,GAAG,MAAM,CAAC,wBAAwB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACrE,IAAI,UAAU,EAAE,YAAY,KAAK,KAAK,IAAI,UAAU,EAAE,QAAQ,KAAK,KAAK,EAAE,CAAC;QACzE,OAAO,CAAC,IAAI,CACV,2FAA2F,CAC5F,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,UAAU,EAAE,CAAC;gBAChC,OAAO,KAAK,CAAC;YACf,CAAC;YAED,OAA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;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,17 +1,23 @@
|
|
|
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
|
+
}
|
|
1
9
|
export type UnknownObject = Record<string, unknown>;
|
|
2
|
-
export type
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
export type RequestModalOptions = {
|
|
14
|
-
title: string;
|
|
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;
|
|
15
21
|
};
|
|
16
22
|
export declare const TOOL_RESPONSE_EVENT_TYPE = "openai:tool_response";
|
|
17
23
|
export declare class ToolResponseEvent extends CustomEvent<{
|
|
@@ -24,47 +30,58 @@ export declare class ToolResponseEvent extends CustomEvent<{
|
|
|
24
30
|
}
|
|
25
31
|
declare global {
|
|
26
32
|
interface Window {
|
|
27
|
-
|
|
33
|
+
skybridge: SkybridgeProperties;
|
|
34
|
+
openai: OpenAiMethods<WidgetState> & OpenAiProperties;
|
|
28
35
|
}
|
|
29
36
|
interface WindowEventMap {
|
|
30
37
|
[SET_GLOBALS_EVENT_TYPE]: SetGlobalsEvent;
|
|
31
38
|
}
|
|
32
39
|
}
|
|
33
|
-
export type
|
|
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> = {
|
|
34
44
|
theme: Theme;
|
|
35
45
|
userAgent: UserAgent;
|
|
36
46
|
locale: string;
|
|
37
47
|
maxHeight: number;
|
|
38
48
|
displayMode: DisplayMode;
|
|
39
49
|
safeArea: SafeArea;
|
|
50
|
+
view: View;
|
|
40
51
|
toolInput: ToolInput;
|
|
41
|
-
toolOutput: ToolOutput |
|
|
52
|
+
toolOutput: ToolOutput | {
|
|
53
|
+
text: string;
|
|
54
|
+
} | null;
|
|
42
55
|
toolResponseMetadata: ToolResponseMetadata | null;
|
|
43
56
|
widgetState: WidgetState | null;
|
|
44
|
-
requestDisplayMode: RequestDisplayMode;
|
|
45
|
-
requestModal: RequestModal;
|
|
46
57
|
};
|
|
47
58
|
export type CallToolArgs = Record<string, unknown> | null;
|
|
48
59
|
export type CallToolResponse = {
|
|
49
|
-
content:
|
|
50
|
-
type: "text";
|
|
51
|
-
text: string;
|
|
52
|
-
}[];
|
|
60
|
+
content: CallToolResult["content"];
|
|
53
61
|
structuredContent: Record<string, unknown>;
|
|
54
62
|
isError: boolean;
|
|
55
63
|
result: string;
|
|
56
|
-
|
|
64
|
+
_meta?: CallToolResult["_meta"];
|
|
65
|
+
};
|
|
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
|
+
};
|
|
57
75
|
};
|
|
58
|
-
export type
|
|
59
|
-
type API<WidgetState extends UnknownObject> = {
|
|
76
|
+
export type OpenAiMethods<WidgetState extends UnknownObject = UnknownObject> = {
|
|
60
77
|
/** Calls a tool on your MCP. Returns the full response. */
|
|
61
|
-
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends
|
|
78
|
+
callTool: <ToolArgs extends CallToolArgs = null, ToolResponse extends CallToolResponse = CallToolResponse>(name: string, args: ToolArgs) => Promise<ToolResponse>;
|
|
62
79
|
/** Triggers a followup turn in the ChatGPT conversation */
|
|
63
80
|
sendFollowUpMessage: (args: {
|
|
64
81
|
prompt: string;
|
|
65
82
|
}) => Promise<void>;
|
|
66
83
|
/** Opens an external link, redirects web page or mobile app */
|
|
67
|
-
openExternal(
|
|
84
|
+
openExternal(args: {
|
|
68
85
|
href: string;
|
|
69
86
|
}): void;
|
|
70
87
|
/** For transitioning an app from inline to fullscreen or pip */
|
|
@@ -77,16 +94,38 @@ type API<WidgetState extends UnknownObject> = {
|
|
|
77
94
|
*/
|
|
78
95
|
mode: DisplayMode;
|
|
79
96
|
}>;
|
|
97
|
+
/**
|
|
98
|
+
* Sets the widget state.
|
|
99
|
+
* This state is persisted across widget renders.
|
|
100
|
+
*/
|
|
80
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
|
+
getFileDownloadUrl: (file: FileMetadata) => Promise<{
|
|
114
|
+
downloadUrl: string;
|
|
115
|
+
}>;
|
|
81
116
|
};
|
|
82
117
|
export declare const SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
83
118
|
export declare class SetGlobalsEvent extends CustomEvent<{
|
|
84
|
-
globals: Partial<
|
|
119
|
+
globals: Partial<OpenAiProperties>;
|
|
85
120
|
}> {
|
|
86
121
|
readonly type = "openai:set_globals";
|
|
87
122
|
}
|
|
88
123
|
export type CallTool = (name: string, args: Record<string, unknown>) => Promise<CallToolResponse>;
|
|
89
|
-
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
|
+
};
|
|
90
129
|
export type Theme = "light" | "dark";
|
|
91
130
|
export type SafeAreaInsets = {
|
|
92
131
|
top: number;
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
package/package.json
CHANGED
|
@@ -1,29 +1,25 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "skybridge",
|
|
3
|
-
"version": "0.0.0-dev.
|
|
3
|
+
"version": "0.0.0-dev.e341b6a",
|
|
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"
|
|
8
12
|
],
|
|
9
13
|
"exports": {
|
|
10
14
|
"./server": {
|
|
11
|
-
"types": "./dist/
|
|
12
|
-
"default": "./dist/
|
|
15
|
+
"types": "./dist/server/index.d.ts",
|
|
16
|
+
"default": "./dist/server/index.js"
|
|
13
17
|
},
|
|
14
18
|
"./web": {
|
|
15
|
-
"types": "./dist/
|
|
16
|
-
"default": "./dist/
|
|
19
|
+
"types": "./dist/web/index.d.ts",
|
|
20
|
+
"default": "./dist/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
|
-
"docs:dev": "pnpm --filter @skybridge/docs start",
|
|
24
|
-
"docs:build": "pnpm --filter @skybridge/docs build",
|
|
25
|
-
"docs:serve": "pnpm --filter @skybridge/docs serve"
|
|
26
|
-
},
|
|
27
23
|
"keywords": [
|
|
28
24
|
"chatgpt",
|
|
29
25
|
"app",
|
|
@@ -33,31 +29,60 @@
|
|
|
33
29
|
"author": "Frédéric Barthelet",
|
|
34
30
|
"license": "ISC",
|
|
35
31
|
"peerDependencies": {
|
|
32
|
+
"@modelcontextprotocol/sdk": ">=1.0.0",
|
|
36
33
|
"react": ">=18.0.0",
|
|
37
34
|
"react-dom": ">=18.0.0"
|
|
38
35
|
},
|
|
39
36
|
"dependencies": {
|
|
40
|
-
"@
|
|
37
|
+
"@babel/core": "^7.28.5",
|
|
38
|
+
"@oclif/core": "^4.8.0",
|
|
41
39
|
"cors": "^2.8.5",
|
|
42
|
-
"
|
|
40
|
+
"dequal": "^2.0.3",
|
|
41
|
+
"es-toolkit": "^1.43.0",
|
|
42
|
+
"express": "^5.2.1",
|
|
43
43
|
"handlebars": "^4.7.8",
|
|
44
|
-
"
|
|
45
|
-
"
|
|
44
|
+
"superjson": "^2.2.6",
|
|
45
|
+
"vite": "^7.3.1",
|
|
46
|
+
"zustand": "^5.0.9"
|
|
46
47
|
},
|
|
47
48
|
"devDependencies": {
|
|
49
|
+
"@modelcontextprotocol/ext-apps": "^0.2.2",
|
|
50
|
+
"@modelcontextprotocol/sdk": "^1.25.2",
|
|
48
51
|
"@testing-library/dom": "^10.4.1",
|
|
49
|
-
"@testing-library/react": "^16.3.
|
|
52
|
+
"@testing-library/react": "^16.3.1",
|
|
50
53
|
"@total-typescript/tsconfig": "^1.0.4",
|
|
54
|
+
"@types/babel__core": "^7.20.5",
|
|
51
55
|
"@types/cors": "^2.8.19",
|
|
52
|
-
"@types/express": "^5.0.
|
|
53
|
-
"@types/jsdom": "^
|
|
54
|
-
"@types/node": "^
|
|
55
|
-
"@types/react": "^19.2.
|
|
56
|
-
"@types/react-dom": "^19.2.
|
|
57
|
-
"@vitest/ui": "^
|
|
58
|
-
"jsdom": "^
|
|
56
|
+
"@types/express": "^5.0.6",
|
|
57
|
+
"@types/jsdom": "^27.0.0",
|
|
58
|
+
"@types/node": "^24.10.4",
|
|
59
|
+
"@types/react": "^19.2.7",
|
|
60
|
+
"@types/react-dom": "^19.2.3",
|
|
61
|
+
"@vitest/ui": "^4.0.16",
|
|
62
|
+
"jsdom": "^27.4.0",
|
|
63
|
+
"shx": "^0.3.4",
|
|
64
|
+
"ts-node": "^10.9.2",
|
|
59
65
|
"typescript": "^5.9.3",
|
|
60
|
-
"vitest": "^
|
|
66
|
+
"vitest": "^4.0.16",
|
|
67
|
+
"zod": "^4.3.5"
|
|
61
68
|
},
|
|
62
|
-
"
|
|
63
|
-
|
|
69
|
+
"bin": {
|
|
70
|
+
"sb": "./bin/run.js",
|
|
71
|
+
"skybridge": "./bin/run.js"
|
|
72
|
+
},
|
|
73
|
+
"oclif": {
|
|
74
|
+
"bin": "skybridge",
|
|
75
|
+
"commands": "./dist/commands",
|
|
76
|
+
"dirname": "skybridge",
|
|
77
|
+
"topicSeparator": " "
|
|
78
|
+
},
|
|
79
|
+
"scripts": {
|
|
80
|
+
"build": "shx rm -rf dist && tsc && pnpm run build:templates",
|
|
81
|
+
"build:templates": "cp -r src/server/templates dist/server/",
|
|
82
|
+
"format": "biome check --write --error-on-warnings",
|
|
83
|
+
"test": "pnpm run test:unit && pnpm run test:type && pnpm run test:format",
|
|
84
|
+
"test:unit": "vitest run",
|
|
85
|
+
"test:type": "tsc --noEmit",
|
|
86
|
+
"test:format": "biome ci"
|
|
87
|
+
}
|
|
88
|
+
}
|
package/README.md
DELETED
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
<div align="center">
|
|
2
|
-
|
|
3
|
-
# Skybridge
|
|
4
|
-
|
|
5
|
-
**Skybridge is the TypeScript framework for building ChatGPT apps**
|
|
6
|
-
|
|
7
|
-
[](https://alpic.ai)
|
|
8
|
-
|
|
9
|
-

|
|
10
|
-

|
|
11
|
-

|
|
12
|
-
|
|
13
|
-
</div>
|
|
14
|
-
|
|
15
|
-
Skybridge comes with 2 packages:
|
|
16
|
-
|
|
17
|
-
- `skybridge/server`: A drop-in replacement of the `@modelcontextprotocol/sdk` official `McpServer` class with extra features for widget development.
|
|
18
|
-
- `skybridge/web`: A react library with hooks and components to build widgets on the underlying _OpenAI iFrame skybridge_ runtime.
|
|
19
|
-
|
|
20
|
-
## Quick start
|
|
21
|
-
|
|
22
|
-
To get started in less than a minute, you can [create a new repository](https://github.com/new?template_name=apps-sdk-template&template_owner=alpic-ai) using our [ChatGPT SDK template](https://github.com/alpic-ai/apps-sdk-template). This template includes a basic setup for both the server and the widgets.
|
|
23
|
-
|
|
24
|
-
## Installation
|
|
25
|
-
|
|
26
|
-
```bash
|
|
27
|
-
pnpm add skybridge
|
|
28
|
-
```
|
|
29
|
-
|
|
30
|
-
## Concepts
|
|
31
|
-
|
|
32
|
-
### Widgets
|
|
33
|
-
|
|
34
|
-
> A widget is a UI component that turns structured tool results into a human-friendly UI. Those are built using React components. They are rendered inside an iframe inline with the conversation on ChatGPT.
|
|
35
|
-
|
|
36
|
-
Each widget in your app must have a unique name. The name is used to bridge the tool invocation result with the widget React component.
|
|
37
|
-
|
|
38
|
-
For example, in order to register a new widget named `pokemon` on your ChatGPT app. You should have the following file structure and file contents:
|
|
39
|
-
|
|
40
|
-
_Project structure_
|
|
41
|
-
|
|
42
|
-
```
|
|
43
|
-
server/
|
|
44
|
-
└── src/
|
|
45
|
-
└── index.ts // Register the widget with McpServer.widget()
|
|
46
|
-
web/
|
|
47
|
-
└── src/
|
|
48
|
-
└── widgets/
|
|
49
|
-
└── pokemon.tsx // Use the same widget name as the file name
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
_server/src/index.ts_
|
|
53
|
-
|
|
54
|
-
```ts
|
|
55
|
-
import { McpServer } from "skybridge/server";
|
|
56
|
-
|
|
57
|
-
const server = new McpServer();
|
|
58
|
-
|
|
59
|
-
server.widget(
|
|
60
|
-
"pokemon"
|
|
61
|
-
// Remaining arguments...
|
|
62
|
-
);
|
|
63
|
-
```
|
|
64
|
-
|
|
65
|
-
_web/src/widgets/pokemon.tsx_
|
|
66
|
-
|
|
67
|
-
```ts
|
|
68
|
-
import { mountWidget } from "skybridge/web";
|
|
69
|
-
|
|
70
|
-
const Pokemon: React.FunctionComponent = () => {
|
|
71
|
-
// Your React component code goes here...
|
|
72
|
-
};
|
|
73
|
-
|
|
74
|
-
mountWidget(<Pokemon />);
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
## Packages
|
|
78
|
-
|
|
79
|
-
### skybridge/server
|
|
80
|
-
|
|
81
|
-
The `skybridge/server` package is a drop-in replacement of the `@modelcontextprotocol/sdk` official `McpServer` class with extra features for widget development. If you're already using the `@modelcontextprotocol/sdk`, you can simply replace your `McpServer` import with `skybridge/server` and you're good to go.
|
|
82
|
-
|
|
83
|
-
### skybridge/web
|
|
84
|
-
|
|
85
|
-
The `skybridge/web` package is a react library with hooks and components to build widgets on the underlying _OpenAI iFrame skybridge_ runtime.
|
|
86
|
-
|
|
87
|
-
**Vite plugin**
|
|
88
|
-
|
|
89
|
-
The `skybridge/web` package comes with a Vite plugin that allows you to build your widgets as regular Vite apps.
|
|
90
|
-
|
|
91
|
-
```ts
|
|
92
|
-
import { defineConfig } from "vite";
|
|
93
|
-
import { skybridge } from "skybridge/web";
|
|
94
|
-
|
|
95
|
-
export default defineConfig({
|
|
96
|
-
plugins: [skybridge()],
|
|
97
|
-
});
|
|
98
|
-
```
|
|
99
|
-
|
|
100
|
-
**Hooks**
|
|
101
|
-
|
|
102
|
-
The `skybridge/web` package comes with a set of hooks to help you build your widgets :
|
|
103
|
-
|
|
104
|
-
- `useOpenAiGlobal`: A generic hook to get any global data from the OpenAI iFrame skybridge runtime (in `window.openai`).
|
|
105
|
-
- `useToolOutput`: A hook to get the initial tool `structuredContent` returned when rendering the widget for the first time. The data inside this hook is not updated when the tool is called again.
|
|
106
|
-
- `useToolResponseMetadata`: A hook to get the initial tool `meta` returned when rendering the widget for the first time. The data inside this hook is not updated when the tool is called again.
|
|
107
|
-
- `useCallTool`: A @tanstack/react-query inspired hook to send make additional tool calls inside a widget.
|
|
108
|
-
|
|
109
|
-
_useOpenAiGlobal_
|
|
110
|
-
|
|
111
|
-
```ts
|
|
112
|
-
import { useOpenAiGlobal } from "skybridge/web";
|
|
113
|
-
|
|
114
|
-
const theme = useOpenAiGlobal("theme");
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
_useToolOutput_
|
|
118
|
-
|
|
119
|
-
```ts
|
|
120
|
-
import { useToolOutput } from "skybridge/web";
|
|
121
|
-
|
|
122
|
-
const toolOutput = useToolOutput();
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
_useToolResponseMetadata_
|
|
126
|
-
|
|
127
|
-
```ts
|
|
128
|
-
import { useToolResponseMetadata } from "skybridge/web";
|
|
129
|
-
|
|
130
|
-
const toolResponseMetadata = useToolResponseMetadata();
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
_useCallTool_ in synchronous mode
|
|
134
|
-
|
|
135
|
-
```ts
|
|
136
|
-
import { useCallTool } from "skybridge/web";
|
|
137
|
-
|
|
138
|
-
export const TestTool: React.FunctionComponent = () => {
|
|
139
|
-
const { callTool, isPending } = useCallTool("myToolName");
|
|
140
|
-
|
|
141
|
-
return (
|
|
142
|
-
<div>
|
|
143
|
-
<button
|
|
144
|
-
disabled={isPending}
|
|
145
|
-
onClick={() => {
|
|
146
|
-
callTool({ input: "test input" }, {
|
|
147
|
-
onSuccess: (data) => {
|
|
148
|
-
alert("Tool returned: " + data);
|
|
149
|
-
},
|
|
150
|
-
});
|
|
151
|
-
>
|
|
152
|
-
Call Tool inside a widget
|
|
153
|
-
</button>
|
|
154
|
-
</div>
|
|
155
|
-
);
|
|
156
|
-
};
|
|
157
|
-
```
|
|
158
|
-
|
|
159
|
-
_useCallTool_ in asynchronous mode
|
|
160
|
-
|
|
161
|
-
```ts
|
|
162
|
-
import { useCallTool } from "skybridge/web";
|
|
163
|
-
|
|
164
|
-
export const TestTool: React.FunctionComponent = () => {
|
|
165
|
-
const { callToolAsync, isPending } = useCallTool("myToolName");
|
|
166
|
-
|
|
167
|
-
return (
|
|
168
|
-
<div>
|
|
169
|
-
<button
|
|
170
|
-
disabled={isPending}
|
|
171
|
-
onClick={async () => {
|
|
172
|
-
const data = await callToolAsync({ input: "test input" });
|
|
173
|
-
alert("Tool returned: " + data);
|
|
174
|
-
}}
|
|
175
|
-
>
|
|
176
|
-
Call Tool inside a widget
|
|
177
|
-
</button>
|
|
178
|
-
</div>
|
|
179
|
-
);
|
|
180
|
-
};
|
|
181
|
-
```
|
|
182
|
-
|
|
183
|
-
## Migrate your existing MCP server to a ChatGPT app
|
|
184
|
-
|
|
185
|
-
If you're already using the `@modelcontextprotocol/sdk` to build a MCP server, you can migrate to a ChatGPT app by following these steps:
|
|
186
|
-
|
|
187
|
-
1. Replace your `McpServer` import from `@modelcontextprotocol/sdk` with the same import from `skybridge/server`
|
|
188
|
-
2. Create a new vite project in a folder named `web` and install the `skybridge` package
|
|
189
|
-
3. Replace the `vite.config.ts` file with the following:
|
|
190
|
-
|
|
191
|
-
```ts
|
|
192
|
-
import { defineConfig } from "vite";
|
|
193
|
-
import { skybridge } from "skybridge/web";
|
|
194
|
-
|
|
195
|
-
export default defineConfig({
|
|
196
|
-
plugins: [skybridge()],
|
|
197
|
-
});
|
|
198
|
-
```
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { McpServer as McpServerBase, type ToolCallback } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import type { Resource } from "@modelcontextprotocol/sdk/types.js";
|
|
3
|
-
import type { ZodRawShape } from "zod";
|
|
4
|
-
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;
|
|
11
|
-
private lookupDistFile;
|
|
12
|
-
}
|
|
13
|
-
export {};
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import { McpServer as McpServerBase, } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
2
|
-
import { templateHelper } from "./templateHelper.js";
|
|
3
|
-
import { readFileSync } from "node:fs";
|
|
4
|
-
import path from "node:path";
|
|
5
|
-
export class McpServer extends McpServerBase {
|
|
6
|
-
widget(name, resourceConfig, toolConfig, toolCallback) {
|
|
7
|
-
const uri = `ui://widgets/${name}.html`;
|
|
8
|
-
const resourceMetadata = { ...(resourceConfig._meta ?? {}) };
|
|
9
|
-
if (toolConfig.description !== undefined) {
|
|
10
|
-
resourceMetadata["openai/widgetDescription"] = toolConfig.description;
|
|
11
|
-
}
|
|
12
|
-
this.resource(name, uri, {
|
|
13
|
-
...resourceConfig,
|
|
14
|
-
_meta: resourceMetadata,
|
|
15
|
-
}, async (_uri, extra) => {
|
|
16
|
-
const serverUrl = process.env.NODE_ENV === "production"
|
|
17
|
-
? `https://${extra?.requestInfo?.headers?.["x-forwarded-host"] ??
|
|
18
|
-
extra?.requestInfo?.headers?.host}`
|
|
19
|
-
: `http://localhost:3000`;
|
|
20
|
-
const html = process.env.NODE_ENV === "production"
|
|
21
|
-
? templateHelper.renderProduction({
|
|
22
|
-
serverUrl,
|
|
23
|
-
widgetFile: this.lookupDistFile(`src/widgets/${name}.tsx`),
|
|
24
|
-
styleFile: this.lookupDistFile("style.css"),
|
|
25
|
-
})
|
|
26
|
-
: templateHelper.renderDevelopment({
|
|
27
|
-
serverUrl,
|
|
28
|
-
widgetName: name,
|
|
29
|
-
});
|
|
30
|
-
return {
|
|
31
|
-
contents: [
|
|
32
|
-
{
|
|
33
|
-
uri,
|
|
34
|
-
mimeType: "text/html+skybridge",
|
|
35
|
-
text: html,
|
|
36
|
-
},
|
|
37
|
-
],
|
|
38
|
-
};
|
|
39
|
-
});
|
|
40
|
-
const toolMeta = {
|
|
41
|
-
...toolConfig._meta,
|
|
42
|
-
"openai/outputTemplate": uri,
|
|
43
|
-
};
|
|
44
|
-
this.registerTool(name, {
|
|
45
|
-
...toolConfig,
|
|
46
|
-
_meta: toolMeta,
|
|
47
|
-
}, toolCallback);
|
|
48
|
-
}
|
|
49
|
-
lookupDistFile(key) {
|
|
50
|
-
const manifest = JSON.parse(readFileSync(path.join(process.cwd(), "dist", "assets", ".vite", "manifest.json"), "utf-8"));
|
|
51
|
-
return manifest[key]?.file;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=server.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AACvC,OAAO,IAAI,MAAM,WAAW,CAAC;AA4B7B,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,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ED,gBAAgB,CAAC,IAIhB;QACC,MAAM,QAAQ,GAAG,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC;QACjD,OAAO,QAAQ,CAAC,IAAI,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,12 +0,0 @@
|
|
|
1
|
-
<base href="{{serverUrl}}" />
|
|
2
|
-
<script type="module">
|
|
3
|
-
import { injectIntoGlobalHook } from "{{serverUrl}}/@react-refresh";
|
|
4
|
-
injectIntoGlobalHook(window); window.$RefreshReg$ = () => {};
|
|
5
|
-
window.$RefreshSig$ = () => (type) => type;
|
|
6
|
-
window.__vite_plugin_react_preamble_installed__ = true;
|
|
7
|
-
</script>
|
|
8
|
-
<script type="module" src="{{serverUrl}}/@vite/client"></script>
|
|
9
|
-
<div id="root"></div>
|
|
10
|
-
<script type="module">
|
|
11
|
-
import('{{serverUrl}}/src/widgets/{{widgetName}}.tsx');
|
|
12
|
-
</script>
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"widgetsDevServer.js","sourceRoot":"","sources":["../../../src/server/widgetsDevServer.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,EAAE,EAAuB,MAAM,SAAS,CAAC;AACvD,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;;;;;;GASG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,KAAK,IAA6B,EAAE;IAClE,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAEhC,MAAM,EAAE,YAAY,EAAE,sBAAsB,EAAE,kBAAkB,EAAE,GAChE,MA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,EAAE,EAAE;IACd,IAAI,EAAE,EAAE,CAAC,EAAE,EAAE;IACb,GAAG,EAAE,EAAE,CAAC,EAAE,EAAE;CACb,CAAC"}
|
package/dist/src/test/utils.d.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { type MockInstance } from "vitest";
|
|
2
|
-
import { McpServer } from "../server/server.js";
|
|
3
|
-
/**
|
|
4
|
-
* Creates a real McpServer instance for testing
|
|
5
|
-
*/
|
|
6
|
-
export declare function createMockMcpServer(): {
|
|
7
|
-
server: McpServer;
|
|
8
|
-
mockResource: MockInstance<McpServer["resource"]>;
|
|
9
|
-
mockRegisterTool: MockInstance<McpServer["registerTool"]>;
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Mock extra parameter for resource callback
|
|
13
|
-
*/
|
|
14
|
-
export declare function createMockExtra(host: string): {
|
|
15
|
-
requestInfo: {
|
|
16
|
-
headers: {
|
|
17
|
-
host: string;
|
|
18
|
-
};
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
/**
|
|
22
|
-
* Sets up environment variables for testing
|
|
23
|
-
*/
|
|
24
|
-
export declare function setTestEnv(env: Record<string, string>): void;
|
|
25
|
-
/**
|
|
26
|
-
* Resets environment variables
|
|
27
|
-
*/
|
|
28
|
-
export declare function resetTestEnv(): void;
|