open-mcp-app 0.0.11 → 0.0.12
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/dist/core/index.d.ts +14 -1
- package/dist/core/index.js +61 -10
- package/dist/core/index.js.map +1 -1
- package/dist/react/index.js +61 -10
- package/dist/react/index.js.map +1 -1
- package/dist/server/index.d.ts +91 -395
- package/dist/server/index.js +333 -451
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/core/index.d.ts
CHANGED
|
@@ -745,6 +745,8 @@ declare class ClaudeDesktopHostClient extends Subscribable implements UnifiedHos
|
|
|
745
745
|
* Available on `window.openai` when running inside ChatGPT.
|
|
746
746
|
*/
|
|
747
747
|
interface OpenAIBridge {
|
|
748
|
+
theme?: string;
|
|
749
|
+
displayMode?: string;
|
|
748
750
|
toolOutput?: Record<string, unknown>;
|
|
749
751
|
widgetState?: WidgetState;
|
|
750
752
|
setWidgetState?: (state: WidgetState) => void;
|
|
@@ -787,6 +789,7 @@ declare class ChatGptWebHostClient extends Subscribable implements UnifiedHostCl
|
|
|
787
789
|
private globalsHandler;
|
|
788
790
|
private lastToolOutputJson;
|
|
789
791
|
private lastWidgetStateJson;
|
|
792
|
+
private hostContext;
|
|
790
793
|
constructor(config: HostClientConfig);
|
|
791
794
|
/**
|
|
792
795
|
* Create a ChatGPT Web host client instance.
|
|
@@ -798,7 +801,7 @@ declare class ChatGptWebHostClient extends Subscribable implements UnifiedHostCl
|
|
|
798
801
|
static detect(): boolean;
|
|
799
802
|
getState(): HostClientState;
|
|
800
803
|
/**
|
|
801
|
-
* Get host context
|
|
804
|
+
* Get host context synthesized from window.openai properties.
|
|
802
805
|
*/
|
|
803
806
|
getHostContext(): HostContext | null;
|
|
804
807
|
subscribe(listener: StateListener): () => void;
|
|
@@ -819,6 +822,11 @@ declare class ChatGptWebHostClient extends Subscribable implements UnifiedHostCl
|
|
|
819
822
|
callTool<T = Record<string, unknown>>(toolName: string, args: Record<string, unknown>): Promise<ToolResult<T>>;
|
|
820
823
|
/**
|
|
821
824
|
* Request a display mode change from the ChatGPT host.
|
|
825
|
+
* Updates internal host context and triggers re-render on success.
|
|
826
|
+
*
|
|
827
|
+
* Note: ChatGPT requires this to be called from a synchronous user event
|
|
828
|
+
* (e.g. click handler). Calling it programmatically on mount will warn
|
|
829
|
+
* and may return undefined.
|
|
822
830
|
*/
|
|
823
831
|
requestDisplayMode(params: {
|
|
824
832
|
mode: DisplayMode;
|
|
@@ -847,6 +855,11 @@ declare class ChatGptWebHostClient extends Subscribable implements UnifiedHostCl
|
|
|
847
855
|
* Update internal state and notify listeners.
|
|
848
856
|
*/
|
|
849
857
|
private setState;
|
|
858
|
+
/**
|
|
859
|
+
* Merge new values into the tracked host context and trigger a re-render
|
|
860
|
+
* so React components see the updated displayMode / theme.
|
|
861
|
+
*/
|
|
862
|
+
private updateHostContext;
|
|
850
863
|
/**
|
|
851
864
|
* Process initial data from `window.openai`.
|
|
852
865
|
*/
|
package/dist/core/index.js
CHANGED
|
@@ -113,6 +113,12 @@ var ChatGptWebHostClient = class _ChatGptWebHostClient extends Subscribable {
|
|
|
113
113
|
globalsHandler = null;
|
|
114
114
|
lastToolOutputJson = null;
|
|
115
115
|
lastWidgetStateJson = null;
|
|
116
|
+
hostContext = {
|
|
117
|
+
theme: "light",
|
|
118
|
+
displayMode: "inline",
|
|
119
|
+
availableDisplayModes: ["inline", "pip", "fullscreen"],
|
|
120
|
+
platform: "web"
|
|
121
|
+
};
|
|
116
122
|
constructor(config) {
|
|
117
123
|
super();
|
|
118
124
|
this.config = config;
|
|
@@ -140,10 +146,10 @@ var ChatGptWebHostClient = class _ChatGptWebHostClient extends Subscribable {
|
|
|
140
146
|
return this.state;
|
|
141
147
|
}
|
|
142
148
|
/**
|
|
143
|
-
* Get host context
|
|
149
|
+
* Get host context synthesized from window.openai properties.
|
|
144
150
|
*/
|
|
145
151
|
getHostContext() {
|
|
146
|
-
return
|
|
152
|
+
return this.hostContext;
|
|
147
153
|
}
|
|
148
154
|
subscribe(listener) {
|
|
149
155
|
return this.subscribeToState(listener);
|
|
@@ -186,21 +192,34 @@ var ChatGptWebHostClient = class _ChatGptWebHostClient extends Subscribable {
|
|
|
186
192
|
type: c2.type,
|
|
187
193
|
text: c2.text || ""
|
|
188
194
|
})),
|
|
189
|
-
source: "ui"
|
|
195
|
+
source: "ui",
|
|
196
|
+
toolName
|
|
190
197
|
};
|
|
191
198
|
this.emit("tool-result", result);
|
|
192
199
|
return result;
|
|
193
200
|
}
|
|
194
201
|
/**
|
|
195
202
|
* Request a display mode change from the ChatGPT host.
|
|
203
|
+
* Updates internal host context and triggers re-render on success.
|
|
204
|
+
*
|
|
205
|
+
* Note: ChatGPT requires this to be called from a synchronous user event
|
|
206
|
+
* (e.g. click handler). Calling it programmatically on mount will warn
|
|
207
|
+
* and may return undefined.
|
|
196
208
|
*/
|
|
197
209
|
async requestDisplayMode(params) {
|
|
198
210
|
const openai = window.openai;
|
|
211
|
+
let grantedMode = params.mode;
|
|
199
212
|
if (openai?.requestDisplayMode) {
|
|
200
|
-
|
|
201
|
-
|
|
213
|
+
try {
|
|
214
|
+
const result = await openai.requestDisplayMode({ mode: params.mode });
|
|
215
|
+
if (result?.mode) {
|
|
216
|
+
grantedMode = result.mode;
|
|
217
|
+
}
|
|
218
|
+
} catch {
|
|
219
|
+
}
|
|
202
220
|
}
|
|
203
|
-
|
|
221
|
+
this.updateHostContext({ displayMode: grantedMode });
|
|
222
|
+
return { mode: grantedMode };
|
|
204
223
|
}
|
|
205
224
|
/**
|
|
206
225
|
* Log a message to the console.
|
|
@@ -302,6 +321,14 @@ var ChatGptWebHostClient = class _ChatGptWebHostClient extends Subscribable {
|
|
|
302
321
|
this.state = { ...this.state, ...partial };
|
|
303
322
|
this.notifyStateChange(this.state, prev);
|
|
304
323
|
}
|
|
324
|
+
/**
|
|
325
|
+
* Merge new values into the tracked host context and trigger a re-render
|
|
326
|
+
* so React components see the updated displayMode / theme.
|
|
327
|
+
*/
|
|
328
|
+
updateHostContext(patch) {
|
|
329
|
+
this.hostContext = { ...this.hostContext, ...patch };
|
|
330
|
+
this.setState({});
|
|
331
|
+
}
|
|
305
332
|
/**
|
|
306
333
|
* Process initial data from `window.openai`.
|
|
307
334
|
*/
|
|
@@ -313,10 +340,21 @@ var ChatGptWebHostClient = class _ChatGptWebHostClient extends Subscribable {
|
|
|
313
340
|
return;
|
|
314
341
|
}
|
|
315
342
|
this.hasProcessedInitialData = true;
|
|
343
|
+
const contextPatch = {};
|
|
344
|
+
if (openai.displayMode) {
|
|
345
|
+
contextPatch.displayMode = openai.displayMode;
|
|
346
|
+
}
|
|
347
|
+
if (openai.theme) {
|
|
348
|
+
contextPatch.theme = openai.theme;
|
|
349
|
+
}
|
|
350
|
+
if (Object.keys(contextPatch).length > 0) {
|
|
351
|
+
this.hostContext = { ...this.hostContext, ...contextPatch };
|
|
352
|
+
}
|
|
316
353
|
this.setState({ isReady: true });
|
|
317
354
|
if (openai.toolOutput) {
|
|
318
355
|
this.emit("tool-input", openai.toolOutput);
|
|
319
|
-
|
|
356
|
+
const toolName = openai.toolOutput?._toolName;
|
|
357
|
+
this.emit("tool-result", { structuredContent: openai.toolOutput, ...toolName && { toolName } });
|
|
320
358
|
}
|
|
321
359
|
if (openai.widgetState) {
|
|
322
360
|
this.setState({ widgetState: openai.widgetState });
|
|
@@ -335,7 +373,8 @@ var ChatGptWebHostClient = class _ChatGptWebHostClient extends Subscribable {
|
|
|
335
373
|
if (toolOutputJson !== this.lastToolOutputJson) {
|
|
336
374
|
this.lastToolOutputJson = toolOutputJson;
|
|
337
375
|
this.emit("tool-input", globals.toolOutput);
|
|
338
|
-
|
|
376
|
+
const toolName = globals.toolOutput?._toolName;
|
|
377
|
+
this.emit("tool-result", { structuredContent: globals.toolOutput, ...toolName && { toolName } });
|
|
339
378
|
}
|
|
340
379
|
}
|
|
341
380
|
if (globals?.widgetState !== void 0) {
|
|
@@ -346,6 +385,16 @@ var ChatGptWebHostClient = class _ChatGptWebHostClient extends Subscribable {
|
|
|
346
385
|
this.emit("widget-state-change", globals.widgetState);
|
|
347
386
|
}
|
|
348
387
|
}
|
|
388
|
+
const contextPatch = {};
|
|
389
|
+
if (globals?.displayMode && globals.displayMode !== this.hostContext.displayMode) {
|
|
390
|
+
contextPatch.displayMode = globals.displayMode;
|
|
391
|
+
}
|
|
392
|
+
if (globals?.theme && globals.theme !== this.hostContext.theme) {
|
|
393
|
+
contextPatch.theme = globals.theme;
|
|
394
|
+
}
|
|
395
|
+
if (Object.keys(contextPatch).length > 0) {
|
|
396
|
+
this.updateHostContext(contextPatch);
|
|
397
|
+
}
|
|
349
398
|
};
|
|
350
399
|
window.addEventListener("openai:set_globals", this.globalsHandler, { passive: true });
|
|
351
400
|
}
|
|
@@ -9746,7 +9795,8 @@ var CreatureDesktopHostClient = class _CreatureDesktopHostClient extends Subscri
|
|
|
9746
9795
|
content: this.extractTextContent(sdkResult.content),
|
|
9747
9796
|
structuredContent: sdkResult.structuredContent,
|
|
9748
9797
|
isError: sdkResult.isError,
|
|
9749
|
-
source: "ui"
|
|
9798
|
+
source: "ui",
|
|
9799
|
+
toolName
|
|
9750
9800
|
};
|
|
9751
9801
|
if (sdkResult.structuredContent && typeof sdkResult.structuredContent === "object") {
|
|
9752
9802
|
const sc = sdkResult.structuredContent;
|
|
@@ -10129,7 +10179,8 @@ var ClaudeDesktopHostClient = class _ClaudeDesktopHostClient extends Subscribabl
|
|
|
10129
10179
|
content: this.extractTextContent(sdkResult.content),
|
|
10130
10180
|
structuredContent: sdkResult.structuredContent,
|
|
10131
10181
|
isError: sdkResult.isError,
|
|
10132
|
-
source: "ui"
|
|
10182
|
+
source: "ui",
|
|
10183
|
+
toolName
|
|
10133
10184
|
};
|
|
10134
10185
|
this.emit("tool-result", result);
|
|
10135
10186
|
return result;
|