mcp-ui-ext-apps-openai 1.0.0
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/README.md +226 -0
- package/dist/chunk-MX7VCLPI.mjs +261 -0
- package/dist/chunk-MX7VCLPI.mjs.map +1 -0
- package/dist/index.d.mts +225 -0
- package/dist/index.d.ts +225 -0
- package/dist/index.js +292 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +17 -0
- package/dist/index.mjs.map +1 -0
- package/dist/react.d.mts +81 -0
- package/dist/react.d.ts +81 -0
- package/dist/react.js +484 -0
- package/dist/react.js.map +1 -0
- package/dist/react.mjs +198 -0
- package/dist/react.mjs.map +1 -0
- package/package.json +60 -0
package/dist/react.mjs
ADDED
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createMCPAdapter,
|
|
3
|
+
createOpenAIAdapter,
|
|
4
|
+
createUnifiedApp,
|
|
5
|
+
detectPlatform,
|
|
6
|
+
isMCP,
|
|
7
|
+
isOpenAI
|
|
8
|
+
} from "./chunk-MX7VCLPI.mjs";
|
|
9
|
+
|
|
10
|
+
// src/use-unified-app.ts
|
|
11
|
+
import { PostMessageTransport } from "@modelcontextprotocol/ext-apps";
|
|
12
|
+
import { useCallback, useEffect, useMemo, useRef, useState } from "react";
|
|
13
|
+
function useOpenAIGlobal(key, initialValue) {
|
|
14
|
+
const [value, setValue] = useState(initialValue);
|
|
15
|
+
useEffect(() => {
|
|
16
|
+
if (typeof window === "undefined" || !window.openai) return;
|
|
17
|
+
const openai = window.openai;
|
|
18
|
+
if (key in openai) {
|
|
19
|
+
setValue(openai[key]);
|
|
20
|
+
}
|
|
21
|
+
const handleChange = () => {
|
|
22
|
+
const currentOpenai = window.openai;
|
|
23
|
+
if (currentOpenai && key in currentOpenai) {
|
|
24
|
+
setValue(currentOpenai[key]);
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
window.addEventListener("openai:set_globals", handleChange);
|
|
28
|
+
return () => window.removeEventListener("openai:set_globals", handleChange);
|
|
29
|
+
}, [key]);
|
|
30
|
+
return value;
|
|
31
|
+
}
|
|
32
|
+
function useUnifiedApp(options) {
|
|
33
|
+
const platformRef = useRef(detectPlatform());
|
|
34
|
+
const platform = platformRef.current;
|
|
35
|
+
const [unifiedApp, setUnifiedApp] = useState(null);
|
|
36
|
+
const [isConnected, setIsConnected] = useState(false);
|
|
37
|
+
const [error, setError] = useState(null);
|
|
38
|
+
const [hostContext, setHostContext] = useState();
|
|
39
|
+
const [localWidgetState, setLocalWidgetState] = useState(null);
|
|
40
|
+
const openaiWidgetState = useOpenAIGlobal("widgetState", null);
|
|
41
|
+
const openaiWidgetProps = useOpenAIGlobal("widget", {});
|
|
42
|
+
const openaiToolOutput = useOpenAIGlobal("toolOutput", void 0);
|
|
43
|
+
const openaiTheme = useOpenAIGlobal("theme", "light");
|
|
44
|
+
const openaiDisplayMode = useOpenAIGlobal("displayMode", "inline");
|
|
45
|
+
const openaiLocale = useOpenAIGlobal("locale", "en-US");
|
|
46
|
+
const optionsRef = useRef(options);
|
|
47
|
+
optionsRef.current = options;
|
|
48
|
+
useEffect(() => {
|
|
49
|
+
if (platform === "openai" && openaiWidgetState !== null) {
|
|
50
|
+
setLocalWidgetState(openaiWidgetState);
|
|
51
|
+
}
|
|
52
|
+
}, [platform, openaiWidgetState]);
|
|
53
|
+
const setWidgetState = useCallback((state) => {
|
|
54
|
+
setLocalWidgetState(state);
|
|
55
|
+
if (unifiedApp && platform === "openai") {
|
|
56
|
+
unifiedApp.setWidgetState(state);
|
|
57
|
+
}
|
|
58
|
+
}, [unifiedApp, platform]);
|
|
59
|
+
const updateWidgetState = useCallback((state) => {
|
|
60
|
+
setLocalWidgetState((prev) => ({ ...prev, ...state }));
|
|
61
|
+
if (unifiedApp && platform === "openai") {
|
|
62
|
+
unifiedApp.updateWidgetState(state);
|
|
63
|
+
}
|
|
64
|
+
}, [unifiedApp, platform]);
|
|
65
|
+
useEffect(() => {
|
|
66
|
+
if (platform === "openai" && isConnected) {
|
|
67
|
+
setHostContext({
|
|
68
|
+
theme: openaiTheme,
|
|
69
|
+
displayMode: openaiDisplayMode,
|
|
70
|
+
locale: openaiLocale,
|
|
71
|
+
safeAreaInsets: window.openai?.safeArea?.insets,
|
|
72
|
+
maxWidth: window.openai?.maxWidth,
|
|
73
|
+
maxHeight: window.openai?.maxHeight
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
}, [platform, isConnected, openaiTheme, openaiDisplayMode, openaiLocale]);
|
|
77
|
+
useEffect(() => {
|
|
78
|
+
let mounted = true;
|
|
79
|
+
let mcpApp = null;
|
|
80
|
+
async function initialize() {
|
|
81
|
+
const opts = optionsRef.current;
|
|
82
|
+
if (platform === "openai") {
|
|
83
|
+
try {
|
|
84
|
+
const adapter = createOpenAIAdapter({
|
|
85
|
+
...opts,
|
|
86
|
+
onToolResult: (result) => {
|
|
87
|
+
opts.onToolResult?.(result);
|
|
88
|
+
},
|
|
89
|
+
onHostContextChanged: (ctx) => {
|
|
90
|
+
if (mounted) {
|
|
91
|
+
setHostContext(ctx);
|
|
92
|
+
opts.onHostContextChanged?.(ctx);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
onError: (err) => {
|
|
96
|
+
console.error(`[${opts.appInfo.name}]`, err);
|
|
97
|
+
opts.onError?.(err);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
if (mounted) {
|
|
101
|
+
setUnifiedApp(adapter);
|
|
102
|
+
setIsConnected(true);
|
|
103
|
+
setHostContext(adapter.getHostContext());
|
|
104
|
+
}
|
|
105
|
+
} catch (err) {
|
|
106
|
+
console.error(`[${opts.appInfo.name}]`, err);
|
|
107
|
+
if (mounted) {
|
|
108
|
+
setError(err);
|
|
109
|
+
setIsConnected(false);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
} else {
|
|
113
|
+
try {
|
|
114
|
+
const { App } = await import("@modelcontextprotocol/ext-apps");
|
|
115
|
+
const transport = new PostMessageTransport(window.parent, window.parent);
|
|
116
|
+
mcpApp = new App(opts.appInfo, opts.capabilities || {});
|
|
117
|
+
mcpApp.onteardown = async () => {
|
|
118
|
+
await opts.onTeardown?.();
|
|
119
|
+
return {};
|
|
120
|
+
};
|
|
121
|
+
mcpApp.ontoolinput = async (input) => {
|
|
122
|
+
await opts.onToolInput?.(input);
|
|
123
|
+
};
|
|
124
|
+
mcpApp.ontoolresult = async (result) => {
|
|
125
|
+
await opts.onToolResult?.(result);
|
|
126
|
+
};
|
|
127
|
+
mcpApp.onerror = (err) => {
|
|
128
|
+
console.error(`[${opts.appInfo.name}]`, err);
|
|
129
|
+
opts.onError?.(err instanceof Error ? err : new Error(String(err)));
|
|
130
|
+
};
|
|
131
|
+
mcpApp.onhostcontextchanged = (params) => {
|
|
132
|
+
if (mounted) {
|
|
133
|
+
setHostContext((prev) => {
|
|
134
|
+
const newCtx = { ...prev, ...params };
|
|
135
|
+
opts.onHostContextChanged?.(newCtx);
|
|
136
|
+
return newCtx;
|
|
137
|
+
});
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
await mcpApp.connect(transport);
|
|
141
|
+
if (mounted) {
|
|
142
|
+
const adapter = createMCPAdapter(mcpApp, opts);
|
|
143
|
+
setUnifiedApp(adapter);
|
|
144
|
+
setIsConnected(true);
|
|
145
|
+
const ctx = mcpApp.getHostContext();
|
|
146
|
+
if (ctx) {
|
|
147
|
+
setHostContext({
|
|
148
|
+
theme: ctx.theme,
|
|
149
|
+
displayMode: ctx.displayMode,
|
|
150
|
+
locale: ctx.locale,
|
|
151
|
+
safeAreaInsets: ctx.safeAreaInsets
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
} catch (err) {
|
|
156
|
+
console.error(`[${opts.appInfo.name}]`, err);
|
|
157
|
+
if (mounted) {
|
|
158
|
+
setError(err instanceof Error ? err : new Error("Failed to connect"));
|
|
159
|
+
setIsConnected(false);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
initialize();
|
|
165
|
+
return () => {
|
|
166
|
+
mounted = false;
|
|
167
|
+
};
|
|
168
|
+
}, [platform]);
|
|
169
|
+
const finalPlatform = useMemo(() => {
|
|
170
|
+
if (platform === "openai") return "openai";
|
|
171
|
+
if (isConnected) return "mcp";
|
|
172
|
+
return "unknown";
|
|
173
|
+
}, [platform, isConnected]);
|
|
174
|
+
const widgetProps = platform === "openai" ? openaiWidgetProps?.props || {} : {};
|
|
175
|
+
const initialProps = platform === "openai" ? openaiToolOutput : void 0;
|
|
176
|
+
return {
|
|
177
|
+
app: unifiedApp,
|
|
178
|
+
isConnected,
|
|
179
|
+
error,
|
|
180
|
+
platform: finalPlatform,
|
|
181
|
+
hostContext,
|
|
182
|
+
initialProps,
|
|
183
|
+
widgetProps,
|
|
184
|
+
widgetState: localWidgetState,
|
|
185
|
+
setWidgetState,
|
|
186
|
+
updateWidgetState
|
|
187
|
+
};
|
|
188
|
+
}
|
|
189
|
+
export {
|
|
190
|
+
createMCPAdapter,
|
|
191
|
+
createOpenAIAdapter,
|
|
192
|
+
createUnifiedApp,
|
|
193
|
+
detectPlatform,
|
|
194
|
+
isMCP,
|
|
195
|
+
isOpenAI,
|
|
196
|
+
useUnifiedApp
|
|
197
|
+
};
|
|
198
|
+
//# sourceMappingURL=react.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/use-unified-app.ts"],"sourcesContent":["/**\n * @file React hook for unified OpenAI/MCP app usage\n *\n * This hook provides a unified interface for apps that need to run on both\n * OpenAI ChatGPT and MCP Apps platforms.\n */\n\nimport type { App, McpUiAppCapabilities } from \"@modelcontextprotocol/ext-apps\";\nimport { PostMessageTransport } from \"@modelcontextprotocol/ext-apps\";\nimport { useCallback, useEffect, useMemo, useRef, useState } from \"react\";\nimport {\n createMCPAdapter,\n createOpenAIAdapter,\n detectPlatform,\n type Platform,\n type UnifiedApp,\n type UnifiedHostContext,\n type UnifiedToolResult,\n} from \"./unified-app\";\n\nexport interface UseUnifiedAppOptions {\n appInfo: { name: string; version: string };\n capabilities?: McpUiAppCapabilities;\n onToolInput?: (input: unknown) => void | Promise<void>;\n onToolResult?: (result: UnifiedToolResult) => void | Promise<void>;\n onHostContextChanged?: (context: UnifiedHostContext) => void;\n onTeardown?: () => void | Promise<void>;\n onError?: (error: Error) => void;\n}\n\nexport interface UseUnifiedAppResult {\n /** The unified app instance */\n app: UnifiedApp | null;\n /** Whether the app is connected to the host */\n isConnected: boolean;\n /** Any connection error */\n error: Error | null;\n /** The detected platform */\n platform: Platform;\n /** Current host context (theme, displayMode, locale, etc.) */\n hostContext: UnifiedHostContext | undefined;\n /** Initial props from toolOutput (OpenAI only, undefined on MCP) - use as initial data for component */\n initialProps: unknown;\n /** Widget props (OpenAI only, reactive) */\n widgetProps: Record<string, unknown>;\n /** Widget state - works on both platforms via React state */\n widgetState: unknown;\n /** Set widget state - works on both platforms (also syncs to OpenAI if on that platform) */\n setWidgetState: <T = unknown>(state: T) => void;\n /** Update widget state partially - works on both platforms */\n updateWidgetState: <T = unknown>(state: Partial<T>) => void;\n}\n\n/**\n * Hook to subscribe to OpenAI global property changes\n * Listens for 'openai:set_globals' events\n */\nfunction useOpenAIGlobal<T>(key: string, initialValue: T): T {\n const [value, setValue] = useState<T>(initialValue);\n\n useEffect(() => {\n if (typeof window === \"undefined\" || !window.openai) return;\n\n // Get initial value - cast to unknown first then to Record\n const openai = window.openai as unknown as Record<string, unknown>;\n if (key in openai) {\n setValue(openai[key] as T);\n }\n\n // Listen for changes\n const handleChange = () => {\n const currentOpenai = window.openai as unknown as Record<string, unknown>;\n if (currentOpenai && key in currentOpenai) {\n setValue(currentOpenai[key] as T);\n }\n };\n\n window.addEventListener(\"openai:set_globals\", handleChange);\n return () => window.removeEventListener(\"openai:set_globals\", handleChange);\n }, [key]);\n\n return value;\n}\n\n/**\n * React hook that provides a unified app interface for both OpenAI and MCP platforms\n *\n * @example\n * ```tsx\n * function MyApp() {\n * const {\n * app,\n * isConnected,\n * platform,\n * hostContext,\n * widgetState,\n * setWidgetState,\n * } = useUnifiedApp({\n * appInfo: { name: \"My App\", version: \"1.0.0\" },\n * capabilities: {},\n * onError: console.error,\n * });\n *\n * const counter = (widgetState as { value?: number } | null)?.value ?? 0;\n *\n * return (\n * <div>\n * <p>Running on: {platform}</p>\n * <p>Counter: {counter}</p>\n * <button onClick={() => setWidgetState({ value: counter + 1 })}>\n * Increment\n * </button>\n * </div>\n * );\n * }\n * ```\n */\nexport function useUnifiedApp(options: UseUnifiedAppOptions): UseUnifiedAppResult {\n // Detect platform once on mount\n const platformRef = useRef<Platform>(detectPlatform());\n const platform = platformRef.current;\n\n const [unifiedApp, setUnifiedApp] = useState<UnifiedApp | null>(null);\n const [isConnected, setIsConnected] = useState(false);\n const [error, setError] = useState<Error | null>(null);\n const [hostContext, setHostContext] = useState<UnifiedHostContext | undefined>();\n\n // React state for widgetState - works on both platforms\n const [localWidgetState, setLocalWidgetState] = useState<unknown>(null);\n\n // OpenAI reactive globals\n const openaiWidgetState = useOpenAIGlobal<unknown>(\"widgetState\", null);\n const openaiWidgetProps = useOpenAIGlobal<Record<string, unknown>>(\"widget\", {});\n const openaiToolOutput = useOpenAIGlobal<unknown>(\"toolOutput\", undefined);\n const openaiTheme = useOpenAIGlobal<\"light\" | \"dark\">(\"theme\", \"light\");\n const openaiDisplayMode = useOpenAIGlobal<string>(\"displayMode\", \"inline\");\n const openaiLocale = useOpenAIGlobal<string>(\"locale\", \"en-US\");\n\n // Store options in ref to avoid stale closures\n const optionsRef = useRef(options);\n optionsRef.current = options;\n\n // Sync OpenAI widgetState to local state when it changes\n useEffect(() => {\n if (platform === \"openai\" && openaiWidgetState !== null) {\n setLocalWidgetState(openaiWidgetState);\n }\n }, [platform, openaiWidgetState]);\n\n // Widget state setters - work on both platforms via React state\n // Also syncs to OpenAI if on that platform\n const setWidgetState = useCallback(<T = unknown>(state: T) => {\n setLocalWidgetState(state);\n if (unifiedApp && platform === \"openai\") {\n unifiedApp.setWidgetState(state);\n }\n }, [unifiedApp, platform]);\n\n const updateWidgetState = useCallback(<T = unknown>(state: Partial<T>) => {\n setLocalWidgetState((prev: unknown) => ({ ...(prev as object), ...state }));\n if (unifiedApp && platform === \"openai\") {\n unifiedApp.updateWidgetState(state);\n }\n }, [unifiedApp, platform]);\n\n // Update host context from OpenAI globals\n useEffect(() => {\n if (platform === \"openai\" && isConnected) {\n setHostContext({\n theme: openaiTheme,\n displayMode: openaiDisplayMode as UnifiedHostContext[\"displayMode\"],\n locale: openaiLocale,\n safeAreaInsets: window.openai?.safeArea?.insets,\n maxWidth: window.openai?.maxWidth,\n maxHeight: window.openai?.maxHeight,\n });\n }\n }, [platform, isConnected, openaiTheme, openaiDisplayMode, openaiLocale]);\n\n useEffect(() => {\n let mounted = true;\n let mcpApp: App | null = null;\n\n async function initialize() {\n const opts = optionsRef.current;\n\n if (platform === \"openai\") {\n // OpenAI platform - use the adapter directly\n try {\n const adapter = createOpenAIAdapter({\n ...opts,\n onToolResult: (result) => {\n opts.onToolResult?.(result);\n },\n onHostContextChanged: (ctx) => {\n if (mounted) {\n setHostContext(ctx);\n opts.onHostContextChanged?.(ctx);\n }\n },\n onError: (err) => {\n console.error(`[${opts.appInfo.name}]`, err);\n opts.onError?.(err);\n },\n });\n\n if (mounted) {\n setUnifiedApp(adapter);\n setIsConnected(true);\n setHostContext(adapter.getHostContext());\n }\n } catch (err) {\n console.error(`[${opts.appInfo.name}]`, err);\n if (mounted) {\n setError(err as Error);\n setIsConnected(false);\n }\n }\n } else {\n // MCP platform - need to dynamically import and create connection\n try {\n // Dynamic import to avoid issues when running on OpenAI\n const { App } = await import(\"@modelcontextprotocol/ext-apps\");\n\n const transport = new PostMessageTransport(window.parent, window.parent);\n mcpApp = new App(opts.appInfo, opts.capabilities || {});\n\n // Set up handlers before connecting\n mcpApp.onteardown = async () => {\n await opts.onTeardown?.();\n return {};\n };\n\n mcpApp.ontoolinput = async (input) => {\n await opts.onToolInput?.(input);\n };\n\n mcpApp.ontoolresult = async (result) => {\n await opts.onToolResult?.(result as UnifiedToolResult);\n };\n\n mcpApp.onerror = (err) => {\n console.error(`[${opts.appInfo.name}]`, err);\n opts.onError?.(err instanceof Error ? err : new Error(String(err)));\n };\n\n mcpApp.onhostcontextchanged = (params) => {\n if (mounted) {\n setHostContext((prev) => {\n const newCtx = { ...prev, ...params } as UnifiedHostContext;\n opts.onHostContextChanged?.(newCtx);\n return newCtx;\n });\n }\n };\n\n await mcpApp.connect(transport);\n\n if (mounted) {\n const adapter = createMCPAdapter(mcpApp, opts);\n setUnifiedApp(adapter);\n setIsConnected(true);\n\n // Get initial host context\n const ctx = mcpApp.getHostContext();\n if (ctx) {\n setHostContext({\n theme: ctx.theme as UnifiedHostContext[\"theme\"],\n displayMode: ctx.displayMode as UnifiedHostContext[\"displayMode\"],\n locale: ctx.locale,\n safeAreaInsets: ctx.safeAreaInsets,\n });\n }\n }\n } catch (err) {\n console.error(`[${opts.appInfo.name}]`, err);\n if (mounted) {\n setError(err instanceof Error ? err : new Error(\"Failed to connect\"));\n setIsConnected(false);\n }\n }\n }\n }\n\n initialize();\n\n return () => {\n mounted = false;\n // Note: MCP App cleanup would go here if needed\n };\n }, [platform]);\n\n // Determine final platform based on connection state\n const finalPlatform: Platform = useMemo(() => {\n if (platform === \"openai\") return \"openai\";\n if (isConnected) return \"mcp\";\n return \"unknown\";\n }, [platform, isConnected]);\n\n // Return platform-appropriate values\n const widgetProps = platform === \"openai\" ? ((openaiWidgetProps as { props?: Record<string, unknown> })?.props || {}) : {};\n const initialProps = platform === \"openai\" ? openaiToolOutput : undefined;\n\n return {\n app: unifiedApp,\n isConnected,\n error,\n platform: finalPlatform,\n hostContext,\n initialProps,\n widgetProps,\n widgetState: localWidgetState,\n setWidgetState,\n updateWidgetState,\n };\n}\n\nexport default useUnifiedApp;\n"],"mappings":";;;;;;;;;;AAQA,SAAS,4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,UAAU,iBAAiB,QAAQ,IAAI;AAC7C,0BAAc,OAAO;AACrB,2BAAe,IAAI;AAGnB,kBAAM,MAAM,OAAO,eAAe;AAClC,gBAAI,KAAK;AACP,6BAAe;AAAA,gBACb,OAAO,IAAI;AAAA,gBACX,aAAa,IAAI;AAAA,gBACjB,QAAQ,IAAI;AAAA,gBACZ,gBAAgB,IAAI;AAAA,cACtB,CAAC;AAAA,YACH;AAAA,UACF;AAAA,QACF,SAAS,KAAK;AACZ,kBAAQ,MAAM,IAAI,KAAK,QAAQ,IAAI,KAAK,GAAG;AAC3C,cAAI,SAAS;AACX,qBAAS,eAAe,QAAQ,MAAM,IAAI,MAAM,mBAAmB,CAAC;AACpE,2BAAe,KAAK;AAAA,UACtB;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAEA,eAAW;AAEX,WAAO,MAAM;AACX,gBAAU;AAAA,IAEZ;AAAA,EACF,GAAG,CAAC,QAAQ,CAAC;AAGb,QAAM,gBAA0B,QAAQ,MAAM;AAC5C,QAAI,aAAa,SAAU,QAAO;AAClC,QAAI,YAAa,QAAO;AACxB,WAAO;AAAA,EACT,GAAG,CAAC,UAAU,WAAW,CAAC;AAG1B,QAAM,cAAc,aAAa,WAAa,mBAA2D,SAAS,CAAC,IAAK,CAAC;AACzH,QAAM,eAAe,aAAa,WAAW,mBAAmB;AAEhE,SAAO;AAAA,IACL,KAAK;AAAA,IACL;AAAA,IACA;AAAA,IACA,UAAU;AAAA,IACV;AAAA,IACA;AAAA,IACA;AAAA,IACA,aAAa;AAAA,IACb;AAAA,IACA;AAAA,EACF;AACF;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "mcp-ui-ext-apps-openai",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Unified utility for building apps that work on both OpenAI ChatGPT and MCP Apps platforms",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.mjs",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.mjs",
|
|
12
|
+
"require": "./dist/index.js"
|
|
13
|
+
},
|
|
14
|
+
"./react": {
|
|
15
|
+
"types": "./dist/react.d.ts",
|
|
16
|
+
"import": "./dist/react.mjs",
|
|
17
|
+
"require": "./dist/react.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "tsup",
|
|
26
|
+
"dev": "tsup --watch",
|
|
27
|
+
"typecheck": "tsc --noEmit",
|
|
28
|
+
"prepublishOnly": "npm run build"
|
|
29
|
+
},
|
|
30
|
+
"keywords": [
|
|
31
|
+
"mcp",
|
|
32
|
+
"openai",
|
|
33
|
+
"chatgpt",
|
|
34
|
+
"unified",
|
|
35
|
+
"cross-platform",
|
|
36
|
+
"react",
|
|
37
|
+
"widget"
|
|
38
|
+
],
|
|
39
|
+
"author": "lkm1developer",
|
|
40
|
+
"license": "MIT",
|
|
41
|
+
"repository": {
|
|
42
|
+
"type": "git",
|
|
43
|
+
"url": "git+https://github.com/lkm1developer/mcp-ui-ext-apps-openai.git"
|
|
44
|
+
},
|
|
45
|
+
"bugs": {
|
|
46
|
+
"url": "https://github.com/lkm1developer/mcp-ui-ext-apps-openai/issues"
|
|
47
|
+
},
|
|
48
|
+
"homepage": "https://github.com/lkm1developer/mcp-ui-ext-apps-openai#readme",
|
|
49
|
+
"peerDependencies": {
|
|
50
|
+
"@modelcontextprotocol/ext-apps": ">=0.1.0",
|
|
51
|
+
"react": ">=18.0.0"
|
|
52
|
+
},
|
|
53
|
+
"devDependencies": {
|
|
54
|
+
"@modelcontextprotocol/ext-apps": "^0.3.0",
|
|
55
|
+
"@types/react": "^18.2.0",
|
|
56
|
+
"react": "^18.2.0",
|
|
57
|
+
"tsup": "^8.0.0",
|
|
58
|
+
"typescript": "^5.0.0"
|
|
59
|
+
}
|
|
60
|
+
}
|