mcp-app-studio 0.5.1 → 0.6.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 +66 -18
- package/dist/{bridge-BXW_-p2R.d.ts → bridge-BKLezf-H.d.ts} +13 -0
- package/dist/{chunk-2OPSDEPI.js → chunk-IEZAKOIG.js} +34 -2
- package/dist/{chunk-4LAH4JH6.js → chunk-QNH5NSRH.js} +0 -19
- package/dist/cli/index.js +162 -133
- package/dist/core/index.d.ts +11 -29
- package/dist/core/index.js +1 -3
- package/dist/index.d.ts +114 -33
- package/dist/index.js +73 -49
- package/dist/platforms/mcp/index.d.ts +2 -2
- package/dist/platforms/mcp/index.js +13 -3
- package/package.json +4 -8
- package/dist/chunk-EPZCYA26.js +0 -162
- package/dist/platforms/chatgpt/index.d.ts +0 -159
- package/dist/platforms/chatgpt/index.js +0 -167
package/dist/chunk-EPZCYA26.js
DELETED
|
@@ -1,162 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
CHATGPT_CAPABILITIES
|
|
3
|
-
} from "./chunk-4LAH4JH6.js";
|
|
4
|
-
|
|
5
|
-
// src/platforms/chatgpt/bridge.ts
|
|
6
|
-
function hostContextChanged(prev, next) {
|
|
7
|
-
if (!prev) return true;
|
|
8
|
-
const keys = /* @__PURE__ */ new Set([...Object.keys(prev), ...Object.keys(next)]);
|
|
9
|
-
for (const key of keys) {
|
|
10
|
-
if (prev[key] !== next[key]) return true;
|
|
11
|
-
}
|
|
12
|
-
return false;
|
|
13
|
-
}
|
|
14
|
-
var ChatGPTBridge = class {
|
|
15
|
-
platform = "chatgpt";
|
|
16
|
-
capabilities = CHATGPT_CAPABILITIES;
|
|
17
|
-
toolInputCallbacks = /* @__PURE__ */ new Set();
|
|
18
|
-
toolResultCallbacks = /* @__PURE__ */ new Set();
|
|
19
|
-
contextCallbacks = /* @__PURE__ */ new Set();
|
|
20
|
-
lastContext = null;
|
|
21
|
-
connected = false;
|
|
22
|
-
get openai() {
|
|
23
|
-
if (!window.openai) {
|
|
24
|
-
throw new Error("ChatGPT bridge not available");
|
|
25
|
-
}
|
|
26
|
-
return window.openai;
|
|
27
|
-
}
|
|
28
|
-
async connect() {
|
|
29
|
-
if (!window.openai) {
|
|
30
|
-
throw new Error(
|
|
31
|
-
"ChatGPT bridge not available. Is this running inside ChatGPT?"
|
|
32
|
-
);
|
|
33
|
-
}
|
|
34
|
-
window.addEventListener("openai:set_globals", this.handleGlobalsChange);
|
|
35
|
-
this.lastContext = this.buildHostContext();
|
|
36
|
-
if (this.openai.toolInput) {
|
|
37
|
-
this.toolInputCallbacks.forEach((cb) => cb(this.openai.toolInput));
|
|
38
|
-
}
|
|
39
|
-
if (this.openai.toolOutput) {
|
|
40
|
-
this.toolResultCallbacks.forEach(
|
|
41
|
-
(cb) => cb({
|
|
42
|
-
structuredContent: this.openai.toolOutput
|
|
43
|
-
})
|
|
44
|
-
);
|
|
45
|
-
}
|
|
46
|
-
this.connected = true;
|
|
47
|
-
}
|
|
48
|
-
disconnect() {
|
|
49
|
-
if (!this.connected) return;
|
|
50
|
-
window.removeEventListener("openai:set_globals", this.handleGlobalsChange);
|
|
51
|
-
this.connected = false;
|
|
52
|
-
this.toolInputCallbacks.clear();
|
|
53
|
-
this.toolResultCallbacks.clear();
|
|
54
|
-
this.contextCallbacks.clear();
|
|
55
|
-
}
|
|
56
|
-
buildHostContext() {
|
|
57
|
-
const g = this.openai;
|
|
58
|
-
return {
|
|
59
|
-
theme: g.theme,
|
|
60
|
-
locale: g.locale,
|
|
61
|
-
displayMode: g.displayMode,
|
|
62
|
-
availableDisplayModes: ["pip", "inline", "fullscreen"],
|
|
63
|
-
containerDimensions: { maxHeight: g.maxHeight },
|
|
64
|
-
platform: this.mapDeviceType(g.userAgent?.device?.type),
|
|
65
|
-
deviceCapabilities: g.userAgent?.capabilities,
|
|
66
|
-
safeAreaInsets: g.safeArea?.insets,
|
|
67
|
-
userAgent: "ChatGPT"
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
mapDeviceType(type) {
|
|
71
|
-
if (type === "mobile" || type === "tablet") return "mobile";
|
|
72
|
-
return "web";
|
|
73
|
-
}
|
|
74
|
-
handleGlobalsChange = () => {
|
|
75
|
-
const newContext = this.buildHostContext();
|
|
76
|
-
if (hostContextChanged(this.lastContext, newContext)) {
|
|
77
|
-
this.lastContext = newContext;
|
|
78
|
-
this.contextCallbacks.forEach((cb) => cb(newContext));
|
|
79
|
-
}
|
|
80
|
-
if (this.openai.toolInput) {
|
|
81
|
-
this.toolInputCallbacks.forEach((cb) => cb(this.openai.toolInput));
|
|
82
|
-
}
|
|
83
|
-
if (this.openai.toolOutput) {
|
|
84
|
-
const result = {
|
|
85
|
-
structuredContent: this.openai.toolOutput
|
|
86
|
-
};
|
|
87
|
-
if (this.openai.toolResponseMetadata) {
|
|
88
|
-
result._meta = this.openai.toolResponseMetadata;
|
|
89
|
-
}
|
|
90
|
-
this.toolResultCallbacks.forEach((cb) => cb(result));
|
|
91
|
-
}
|
|
92
|
-
};
|
|
93
|
-
getHostContext() {
|
|
94
|
-
return this.lastContext;
|
|
95
|
-
}
|
|
96
|
-
onToolInput(callback) {
|
|
97
|
-
this.toolInputCallbacks.add(callback);
|
|
98
|
-
if (this.connected && this.openai.toolInput) {
|
|
99
|
-
callback(this.openai.toolInput);
|
|
100
|
-
}
|
|
101
|
-
return () => this.toolInputCallbacks.delete(callback);
|
|
102
|
-
}
|
|
103
|
-
onToolResult(callback) {
|
|
104
|
-
this.toolResultCallbacks.add(callback);
|
|
105
|
-
if (this.connected && this.openai.toolOutput) {
|
|
106
|
-
const result = {
|
|
107
|
-
structuredContent: this.openai.toolOutput
|
|
108
|
-
};
|
|
109
|
-
if (this.openai.toolResponseMetadata) {
|
|
110
|
-
result._meta = this.openai.toolResponseMetadata;
|
|
111
|
-
}
|
|
112
|
-
callback(result);
|
|
113
|
-
}
|
|
114
|
-
return () => this.toolResultCallbacks.delete(callback);
|
|
115
|
-
}
|
|
116
|
-
onHostContextChanged(callback) {
|
|
117
|
-
this.contextCallbacks.add(callback);
|
|
118
|
-
return () => this.contextCallbacks.delete(callback);
|
|
119
|
-
}
|
|
120
|
-
async callTool(name, args) {
|
|
121
|
-
const result = await this.openai.callTool(name, args);
|
|
122
|
-
return { structuredContent: result };
|
|
123
|
-
}
|
|
124
|
-
async openLink(url) {
|
|
125
|
-
this.openai.openExternal({ href: url });
|
|
126
|
-
}
|
|
127
|
-
async requestDisplayMode(mode) {
|
|
128
|
-
const result = await this.openai.requestDisplayMode({ mode });
|
|
129
|
-
return result.mode;
|
|
130
|
-
}
|
|
131
|
-
sendSizeChanged(size) {
|
|
132
|
-
if (size.height != null) {
|
|
133
|
-
this.openai.notifyIntrinsicHeight(size.height);
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
async sendMessage(message) {
|
|
137
|
-
const text = message.content.filter((c) => c.type === "text").map((c) => c.text).join("\n");
|
|
138
|
-
await this.openai.sendFollowUpMessage({ prompt: text });
|
|
139
|
-
}
|
|
140
|
-
setWidgetState(state) {
|
|
141
|
-
this.openai.setWidgetState(state);
|
|
142
|
-
}
|
|
143
|
-
getWidgetState() {
|
|
144
|
-
return this.openai.widgetState;
|
|
145
|
-
}
|
|
146
|
-
async uploadFile(file) {
|
|
147
|
-
return this.openai.uploadFile(file);
|
|
148
|
-
}
|
|
149
|
-
async getFileDownloadUrl(fileId) {
|
|
150
|
-
return this.openai.getFileDownloadUrl({ fileId });
|
|
151
|
-
}
|
|
152
|
-
requestClose() {
|
|
153
|
-
this.openai.requestClose();
|
|
154
|
-
}
|
|
155
|
-
async requestModal(options) {
|
|
156
|
-
await this.openai.requestModal(options);
|
|
157
|
-
}
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
export {
|
|
161
|
-
ChatGPTBridge
|
|
162
|
-
};
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { ExtendedBridge, HostCapabilities, HostContext, ToolInputCallback, ToolResultCallback, HostContextChangedCallback, ToolResult, DisplayMode, ChatMessage } from '../../core/index.js';
|
|
2
|
-
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
3
|
-
import { ReactNode } from 'react';
|
|
4
|
-
|
|
5
|
-
interface ChatGPTGlobals {
|
|
6
|
-
theme: "light" | "dark";
|
|
7
|
-
locale: string;
|
|
8
|
-
displayMode: "pip" | "inline" | "fullscreen";
|
|
9
|
-
previousDisplayMode: "pip" | "inline" | "fullscreen" | null;
|
|
10
|
-
maxHeight: number;
|
|
11
|
-
toolInput: Record<string, unknown>;
|
|
12
|
-
toolOutput: Record<string, unknown> | null;
|
|
13
|
-
toolResponseMetadata: Record<string, unknown> | null;
|
|
14
|
-
widgetState: Record<string, unknown> | null;
|
|
15
|
-
userAgent: {
|
|
16
|
-
device: {
|
|
17
|
-
type: "mobile" | "tablet" | "desktop" | "resizable";
|
|
18
|
-
};
|
|
19
|
-
capabilities: {
|
|
20
|
-
hover: boolean;
|
|
21
|
-
touch: boolean;
|
|
22
|
-
};
|
|
23
|
-
};
|
|
24
|
-
safeArea: {
|
|
25
|
-
insets: {
|
|
26
|
-
top: number;
|
|
27
|
-
bottom: number;
|
|
28
|
-
left: number;
|
|
29
|
-
right: number;
|
|
30
|
-
};
|
|
31
|
-
};
|
|
32
|
-
view: {
|
|
33
|
-
mode: "modal" | "inline";
|
|
34
|
-
params: Record<string, unknown> | null;
|
|
35
|
-
} | null;
|
|
36
|
-
userLocation: {
|
|
37
|
-
city?: string;
|
|
38
|
-
region?: string;
|
|
39
|
-
country?: string;
|
|
40
|
-
timezone?: string;
|
|
41
|
-
longitude?: number;
|
|
42
|
-
latitude?: number;
|
|
43
|
-
} | null;
|
|
44
|
-
}
|
|
45
|
-
declare global {
|
|
46
|
-
interface Window {
|
|
47
|
-
openai?: ChatGPTGlobals & {
|
|
48
|
-
callTool(name: string, args: Record<string, unknown>): Promise<unknown>;
|
|
49
|
-
setWidgetState(state: Record<string, unknown> | null): void;
|
|
50
|
-
requestDisplayMode(args: {
|
|
51
|
-
mode: string;
|
|
52
|
-
}): Promise<{
|
|
53
|
-
mode: string;
|
|
54
|
-
}>;
|
|
55
|
-
notifyIntrinsicHeight(height: number): void;
|
|
56
|
-
requestClose(): void;
|
|
57
|
-
sendFollowUpMessage(args: {
|
|
58
|
-
prompt: string;
|
|
59
|
-
}): Promise<void>;
|
|
60
|
-
openExternal(payload: {
|
|
61
|
-
href: string;
|
|
62
|
-
}): void;
|
|
63
|
-
uploadFile(file: File): Promise<{
|
|
64
|
-
fileId: string;
|
|
65
|
-
}>;
|
|
66
|
-
getFileDownloadUrl(args: {
|
|
67
|
-
fileId: string;
|
|
68
|
-
}): Promise<{
|
|
69
|
-
downloadUrl: string;
|
|
70
|
-
}>;
|
|
71
|
-
requestModal(options: unknown): Promise<void>;
|
|
72
|
-
};
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
declare class ChatGPTBridge implements ExtendedBridge {
|
|
77
|
-
readonly platform: "chatgpt";
|
|
78
|
-
readonly capabilities: HostCapabilities;
|
|
79
|
-
private toolInputCallbacks;
|
|
80
|
-
private toolResultCallbacks;
|
|
81
|
-
private contextCallbacks;
|
|
82
|
-
private lastContext;
|
|
83
|
-
private connected;
|
|
84
|
-
private get openai();
|
|
85
|
-
connect(): Promise<void>;
|
|
86
|
-
disconnect(): void;
|
|
87
|
-
private buildHostContext;
|
|
88
|
-
private mapDeviceType;
|
|
89
|
-
private handleGlobalsChange;
|
|
90
|
-
getHostContext(): HostContext | null;
|
|
91
|
-
onToolInput(callback: ToolInputCallback): () => void;
|
|
92
|
-
onToolResult(callback: ToolResultCallback): () => void;
|
|
93
|
-
onHostContextChanged(callback: HostContextChangedCallback): () => void;
|
|
94
|
-
callTool(name: string, args: Record<string, unknown>): Promise<ToolResult>;
|
|
95
|
-
openLink(url: string): Promise<void>;
|
|
96
|
-
requestDisplayMode(mode: DisplayMode): Promise<DisplayMode>;
|
|
97
|
-
sendSizeChanged(size: {
|
|
98
|
-
width?: number;
|
|
99
|
-
height?: number;
|
|
100
|
-
}): void;
|
|
101
|
-
sendMessage(message: ChatMessage): Promise<void>;
|
|
102
|
-
setWidgetState(state: Record<string, unknown> | null): void;
|
|
103
|
-
getWidgetState(): Record<string, unknown> | null;
|
|
104
|
-
uploadFile(file: File): Promise<{
|
|
105
|
-
fileId: string;
|
|
106
|
-
}>;
|
|
107
|
-
getFileDownloadUrl(fileId: string): Promise<{
|
|
108
|
-
downloadUrl: string;
|
|
109
|
-
}>;
|
|
110
|
-
requestClose(): void;
|
|
111
|
-
requestModal(options: {
|
|
112
|
-
title?: string;
|
|
113
|
-
params?: Record<string, unknown>;
|
|
114
|
-
anchor?: {
|
|
115
|
-
x: number;
|
|
116
|
-
y: number;
|
|
117
|
-
width: number;
|
|
118
|
-
height: number;
|
|
119
|
-
};
|
|
120
|
-
}): Promise<void>;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
declare function ChatGPTProvider({ children }: {
|
|
124
|
-
children: ReactNode;
|
|
125
|
-
}): react_jsx_runtime.JSX.Element | null;
|
|
126
|
-
declare function useHostContext(): HostContext | null;
|
|
127
|
-
declare function useTheme(): "light" | "dark";
|
|
128
|
-
declare function useToolInput<T = Record<string, unknown>>(): T | null;
|
|
129
|
-
declare function useToolResult(): ToolResult | null;
|
|
130
|
-
declare function useDisplayMode(): [
|
|
131
|
-
DisplayMode,
|
|
132
|
-
(mode: DisplayMode) => Promise<void>
|
|
133
|
-
];
|
|
134
|
-
declare function useWidgetState<T = Record<string, unknown>>(): [
|
|
135
|
-
T | null,
|
|
136
|
-
(state: T | null) => void
|
|
137
|
-
];
|
|
138
|
-
declare function useCallTool(): (name: string, args: Record<string, unknown>) => Promise<ToolResult>;
|
|
139
|
-
declare function useOpenLink(): (url: string) => Promise<void>;
|
|
140
|
-
declare function useSendMessage(): (text: string) => Promise<void>;
|
|
141
|
-
declare function useUploadFile(): (file: File) => Promise<{
|
|
142
|
-
fileId: string;
|
|
143
|
-
}>;
|
|
144
|
-
declare function useGetFileDownloadUrl(): (fileId: string) => Promise<{
|
|
145
|
-
downloadUrl: string;
|
|
146
|
-
}>;
|
|
147
|
-
declare function useRequestClose(): () => void;
|
|
148
|
-
declare function useRequestModal(): (options: {
|
|
149
|
-
title?: string;
|
|
150
|
-
params?: Record<string, unknown>;
|
|
151
|
-
anchor?: {
|
|
152
|
-
x: number;
|
|
153
|
-
y: number;
|
|
154
|
-
width: number;
|
|
155
|
-
height: number;
|
|
156
|
-
};
|
|
157
|
-
}) => Promise<void>;
|
|
158
|
-
|
|
159
|
-
export { ChatGPTBridge, type ChatGPTGlobals, ChatGPTProvider, useCallTool, useDisplayMode, useGetFileDownloadUrl, useHostContext, useOpenLink, useRequestClose, useRequestModal, useSendMessage, useTheme, useToolInput, useToolResult, useUploadFile, useWidgetState };
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
ChatGPTBridge
|
|
3
|
-
} from "../../chunk-EPZCYA26.js";
|
|
4
|
-
import "../../chunk-4LAH4JH6.js";
|
|
5
|
-
|
|
6
|
-
// src/platforms/chatgpt/hooks.tsx
|
|
7
|
-
import {
|
|
8
|
-
createContext,
|
|
9
|
-
useContext,
|
|
10
|
-
useEffect,
|
|
11
|
-
useState,
|
|
12
|
-
useCallback
|
|
13
|
-
} from "react";
|
|
14
|
-
import { jsx } from "react/jsx-runtime";
|
|
15
|
-
var ChatGPTContext = createContext(null);
|
|
16
|
-
function ChatGPTProvider({ children }) {
|
|
17
|
-
const [bridge] = useState(() => new ChatGPTBridge());
|
|
18
|
-
const [ready, setReady] = useState(false);
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
bridge.connect().then(() => setReady(true));
|
|
21
|
-
}, [bridge]);
|
|
22
|
-
if (!ready) return null;
|
|
23
|
-
return /* @__PURE__ */ jsx(ChatGPTContext.Provider, { value: bridge, children });
|
|
24
|
-
}
|
|
25
|
-
function useChatGPTBridge() {
|
|
26
|
-
const bridge = useContext(ChatGPTContext);
|
|
27
|
-
if (!bridge) {
|
|
28
|
-
throw new Error("useChatGPT* hooks must be used within ChatGPTProvider");
|
|
29
|
-
}
|
|
30
|
-
return bridge;
|
|
31
|
-
}
|
|
32
|
-
function useHostContext() {
|
|
33
|
-
const bridge = useChatGPTBridge();
|
|
34
|
-
const [context, setContext] = useState(
|
|
35
|
-
bridge.getHostContext()
|
|
36
|
-
);
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
return bridge.onHostContextChanged((ctx) => {
|
|
39
|
-
setContext((prev) => ({ ...prev, ...ctx }));
|
|
40
|
-
});
|
|
41
|
-
}, [bridge]);
|
|
42
|
-
return context;
|
|
43
|
-
}
|
|
44
|
-
function useTheme() {
|
|
45
|
-
const bridge = useChatGPTBridge();
|
|
46
|
-
const [theme, setTheme] = useState(
|
|
47
|
-
() => bridge.getHostContext()?.theme ?? "light"
|
|
48
|
-
);
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
return bridge.onHostContextChanged((ctx) => {
|
|
51
|
-
if (ctx.theme !== void 0) {
|
|
52
|
-
setTheme(ctx.theme);
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
}, [bridge]);
|
|
56
|
-
return theme;
|
|
57
|
-
}
|
|
58
|
-
function useToolInput() {
|
|
59
|
-
const bridge = useChatGPTBridge();
|
|
60
|
-
const [input, setInput] = useState(null);
|
|
61
|
-
useEffect(() => {
|
|
62
|
-
return bridge.onToolInput((args) => setInput(args));
|
|
63
|
-
}, [bridge]);
|
|
64
|
-
return input;
|
|
65
|
-
}
|
|
66
|
-
function useToolResult() {
|
|
67
|
-
const bridge = useChatGPTBridge();
|
|
68
|
-
const [result, setResult] = useState(null);
|
|
69
|
-
useEffect(() => {
|
|
70
|
-
return bridge.onToolResult(setResult);
|
|
71
|
-
}, [bridge]);
|
|
72
|
-
return result;
|
|
73
|
-
}
|
|
74
|
-
function useDisplayMode() {
|
|
75
|
-
const bridge = useChatGPTBridge();
|
|
76
|
-
const [mode, setModeState] = useState(
|
|
77
|
-
() => bridge.getHostContext()?.displayMode ?? "inline"
|
|
78
|
-
);
|
|
79
|
-
useEffect(() => {
|
|
80
|
-
return bridge.onHostContextChanged((ctx) => {
|
|
81
|
-
if (ctx.displayMode !== void 0) {
|
|
82
|
-
setModeState(ctx.displayMode);
|
|
83
|
-
}
|
|
84
|
-
});
|
|
85
|
-
}, [bridge]);
|
|
86
|
-
const setMode = useCallback(
|
|
87
|
-
async (newMode) => {
|
|
88
|
-
await bridge.requestDisplayMode(newMode);
|
|
89
|
-
},
|
|
90
|
-
[bridge]
|
|
91
|
-
);
|
|
92
|
-
return [mode, setMode];
|
|
93
|
-
}
|
|
94
|
-
function useWidgetState() {
|
|
95
|
-
const bridge = useChatGPTBridge();
|
|
96
|
-
const [state, setState] = useState(
|
|
97
|
-
() => bridge.getWidgetState()
|
|
98
|
-
);
|
|
99
|
-
const setWidgetState = useCallback(
|
|
100
|
-
(newState) => {
|
|
101
|
-
bridge.setWidgetState(newState);
|
|
102
|
-
setState(newState);
|
|
103
|
-
},
|
|
104
|
-
[bridge]
|
|
105
|
-
);
|
|
106
|
-
return [state, setWidgetState];
|
|
107
|
-
}
|
|
108
|
-
function useCallTool() {
|
|
109
|
-
const bridge = useChatGPTBridge();
|
|
110
|
-
return useCallback(
|
|
111
|
-
(name, args) => bridge.callTool(name, args),
|
|
112
|
-
[bridge]
|
|
113
|
-
);
|
|
114
|
-
}
|
|
115
|
-
function useOpenLink() {
|
|
116
|
-
const bridge = useChatGPTBridge();
|
|
117
|
-
return useCallback((url) => bridge.openLink(url), [bridge]);
|
|
118
|
-
}
|
|
119
|
-
function useSendMessage() {
|
|
120
|
-
const bridge = useChatGPTBridge();
|
|
121
|
-
return useCallback(
|
|
122
|
-
(text) => bridge.sendMessage({
|
|
123
|
-
role: "user",
|
|
124
|
-
content: [{ type: "text", text }]
|
|
125
|
-
}),
|
|
126
|
-
[bridge]
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
function useUploadFile() {
|
|
130
|
-
const bridge = useChatGPTBridge();
|
|
131
|
-
return useCallback((file) => bridge.uploadFile(file), [bridge]);
|
|
132
|
-
}
|
|
133
|
-
function useGetFileDownloadUrl() {
|
|
134
|
-
const bridge = useChatGPTBridge();
|
|
135
|
-
return useCallback(
|
|
136
|
-
(fileId) => bridge.getFileDownloadUrl(fileId),
|
|
137
|
-
[bridge]
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
function useRequestClose() {
|
|
141
|
-
const bridge = useChatGPTBridge();
|
|
142
|
-
return useCallback(() => bridge.requestClose(), [bridge]);
|
|
143
|
-
}
|
|
144
|
-
function useRequestModal() {
|
|
145
|
-
const bridge = useChatGPTBridge();
|
|
146
|
-
return useCallback(
|
|
147
|
-
(options) => bridge.requestModal(options),
|
|
148
|
-
[bridge]
|
|
149
|
-
);
|
|
150
|
-
}
|
|
151
|
-
export {
|
|
152
|
-
ChatGPTBridge,
|
|
153
|
-
ChatGPTProvider,
|
|
154
|
-
useCallTool,
|
|
155
|
-
useDisplayMode,
|
|
156
|
-
useGetFileDownloadUrl,
|
|
157
|
-
useHostContext,
|
|
158
|
-
useOpenLink,
|
|
159
|
-
useRequestClose,
|
|
160
|
-
useRequestModal,
|
|
161
|
-
useSendMessage,
|
|
162
|
-
useTheme,
|
|
163
|
-
useToolInput,
|
|
164
|
-
useToolResult,
|
|
165
|
-
useUploadFile,
|
|
166
|
-
useWidgetState
|
|
167
|
-
};
|