mcp-use 1.5.0-canary.0 → 1.5.0-canary.1
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/.tsbuildinfo +1 -1
- package/dist/{chunk-RE7EYFDV.js → chunk-5XVM4A23.js} +446 -964
- package/dist/index.cjs +474 -992
- package/dist/index.js +11 -5
- package/dist/src/react/ErrorBoundary.d.ts +24 -0
- package/dist/src/react/ErrorBoundary.d.ts.map +1 -0
- package/dist/src/react/Image.d.ts +11 -0
- package/dist/src/react/Image.d.ts.map +1 -0
- package/dist/src/react/McpUseProvider.d.ts +46 -0
- package/dist/src/react/McpUseProvider.d.ts.map +1 -0
- package/dist/src/react/ThemeProvider.d.ts +14 -0
- package/dist/src/react/ThemeProvider.d.ts.map +1 -0
- package/dist/src/react/WidgetControls.d.ts +44 -0
- package/dist/src/react/WidgetControls.d.ts.map +1 -0
- package/dist/src/react/index.cjs +474 -992
- package/dist/src/react/index.d.ts +9 -6
- package/dist/src/react/index.d.ts.map +1 -1
- package/dist/src/react/index.js +11 -5
- package/dist/src/react/useWidget.d.ts.map +1 -1
- package/dist/src/react/widget-types.d.ts +6 -0
- package/dist/src/react/widget-types.d.ts.map +1 -1
- package/dist/src/server/connect-adapter.d.ts.map +1 -1
- package/dist/src/server/index.cjs +232 -21
- package/dist/src/server/index.js +232 -21
- package/dist/src/server/mcp-server.d.ts.map +1 -1
- package/package.json +6 -4
- package/dist/src/react/WidgetDebugger.d.ts +0 -31
- package/dist/src/react/WidgetDebugger.d.ts.map +0 -1
- package/dist/src/react/WidgetFullscreenWrapper.d.ts +0 -32
- package/dist/src/react/WidgetFullscreenWrapper.d.ts.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -995,7 +995,9 @@ __export(index_exports, {
|
|
|
995
995
|
BrowserOAuthClientProvider: () => BrowserOAuthClientProvider,
|
|
996
996
|
ConnectMCPServerTool: () => ConnectMCPServerTool,
|
|
997
997
|
E2BCodeExecutor: () => E2BCodeExecutor,
|
|
998
|
+
ErrorBoundary: () => ErrorBoundary,
|
|
998
999
|
HttpConnector: () => HttpConnector,
|
|
1000
|
+
Image: () => Image,
|
|
999
1001
|
LINEAR_OAUTH_CONFIG: () => LINEAR_OAUTH_CONFIG,
|
|
1000
1002
|
LangChainAdapter: () => LangChainAdapter,
|
|
1001
1003
|
ListMCPServersTool: () => ListMCPServersTool,
|
|
@@ -1003,6 +1005,7 @@ __export(index_exports, {
|
|
|
1003
1005
|
MCPAgent: () => MCPAgent,
|
|
1004
1006
|
MCPClient: () => MCPClient,
|
|
1005
1007
|
MCPSession: () => MCPSession,
|
|
1008
|
+
McpUseProvider: () => McpUseProvider,
|
|
1006
1009
|
OAuthHelper: () => OAuthHelper,
|
|
1007
1010
|
ObservabilityManager: () => ObservabilityManager,
|
|
1008
1011
|
PROMPTS: () => PROMPTS,
|
|
@@ -1011,10 +1014,10 @@ __export(index_exports, {
|
|
|
1011
1014
|
ServerManager: () => ServerManager,
|
|
1012
1015
|
StdioConnector: () => StdioConnector,
|
|
1013
1016
|
Telemetry: () => Telemetry,
|
|
1017
|
+
ThemeProvider: () => ThemeProvider,
|
|
1014
1018
|
VMCodeExecutor: () => VMCodeExecutor,
|
|
1015
1019
|
WebSocketConnector: () => WebSocketConnector,
|
|
1016
|
-
|
|
1017
|
-
WidgetFullscreenWrapper: () => WidgetFullscreenWrapper,
|
|
1020
|
+
WidgetControls: () => WidgetControls,
|
|
1018
1021
|
createOAuthMCPConfig: () => createOAuthMCPConfig,
|
|
1019
1022
|
createReadableStreamFromGenerator: () => createReadableStreamFromGenerator,
|
|
1020
1023
|
isVMAvailable: () => isVMAvailable,
|
|
@@ -7516,15 +7519,61 @@ function useMcp(options) {
|
|
|
7516
7519
|
}
|
|
7517
7520
|
__name(useMcp, "useMcp");
|
|
7518
7521
|
|
|
7522
|
+
// src/react/ErrorBoundary.tsx
|
|
7523
|
+
var import_react2 = __toESM(require("react"), 1);
|
|
7524
|
+
var ErrorBoundary = class extends import_react2.default.Component {
|
|
7525
|
+
static {
|
|
7526
|
+
__name(this, "ErrorBoundary");
|
|
7527
|
+
}
|
|
7528
|
+
constructor(props) {
|
|
7529
|
+
super(props);
|
|
7530
|
+
this.state = { hasError: false, error: null };
|
|
7531
|
+
}
|
|
7532
|
+
static getDerivedStateFromError(error) {
|
|
7533
|
+
return { hasError: true, error };
|
|
7534
|
+
}
|
|
7535
|
+
componentDidCatch(error, errorInfo) {
|
|
7536
|
+
console.error("Widget Error:", error, errorInfo);
|
|
7537
|
+
}
|
|
7538
|
+
render() {
|
|
7539
|
+
if (this.state.hasError) {
|
|
7540
|
+
return /* @__PURE__ */ import_react2.default.createElement("div", { className: "p-4 border border-red-500 bg-red-50 text-red-900 rounded-md dark:bg-red-900/20 dark:text-red-100" }, /* @__PURE__ */ import_react2.default.createElement("h3", { className: "font-bold mb-2" }, "Widget Error"), /* @__PURE__ */ import_react2.default.createElement("pre", { className: "text-sm whitespace-pre-wrap" }, this.state.error?.message));
|
|
7541
|
+
}
|
|
7542
|
+
return this.props.children;
|
|
7543
|
+
}
|
|
7544
|
+
};
|
|
7545
|
+
|
|
7546
|
+
// src/react/Image.tsx
|
|
7547
|
+
var import_react3 = __toESM(require("react"), 1);
|
|
7548
|
+
var Image = /* @__PURE__ */ __name(({ src, ...props }) => {
|
|
7549
|
+
const publicUrl = typeof window !== "undefined" && window.__mcpPublicUrl ? window.__mcpPublicUrl : "";
|
|
7550
|
+
const getFinalSrc = /* @__PURE__ */ __name((source) => {
|
|
7551
|
+
if (!source) return source;
|
|
7552
|
+
if (source.startsWith("http://") || source.startsWith("https://") || source.startsWith("data:")) {
|
|
7553
|
+
return source;
|
|
7554
|
+
}
|
|
7555
|
+
if (!publicUrl) {
|
|
7556
|
+
return source;
|
|
7557
|
+
}
|
|
7558
|
+
const cleanSrc = source.startsWith("/") ? source.slice(1) : source;
|
|
7559
|
+
return `${publicUrl}/${cleanSrc}`;
|
|
7560
|
+
}, "getFinalSrc");
|
|
7561
|
+
const finalSrc = getFinalSrc(src);
|
|
7562
|
+
return /* @__PURE__ */ import_react3.default.createElement("img", { src: finalSrc, ...props });
|
|
7563
|
+
}, "Image");
|
|
7564
|
+
|
|
7565
|
+
// src/react/ThemeProvider.tsx
|
|
7566
|
+
var import_react5 = __toESM(require("react"), 1);
|
|
7567
|
+
|
|
7519
7568
|
// src/react/useWidget.ts
|
|
7520
|
-
var
|
|
7569
|
+
var import_react4 = require("react");
|
|
7521
7570
|
|
|
7522
7571
|
// src/react/widget-types.ts
|
|
7523
7572
|
var SET_GLOBALS_EVENT_TYPE = "openai:set_globals";
|
|
7524
7573
|
|
|
7525
7574
|
// src/react/useWidget.ts
|
|
7526
7575
|
function useOpenAiGlobal(key) {
|
|
7527
|
-
return (0,
|
|
7576
|
+
return (0, import_react4.useSyncExternalStore)(
|
|
7528
7577
|
(onChange) => {
|
|
7529
7578
|
const handleSetGlobal = /* @__PURE__ */ __name((event) => {
|
|
7530
7579
|
const customEvent = event;
|
|
@@ -7548,10 +7597,10 @@ function useOpenAiGlobal(key) {
|
|
|
7548
7597
|
}
|
|
7549
7598
|
__name(useOpenAiGlobal, "useOpenAiGlobal");
|
|
7550
7599
|
function useWidget(defaultProps) {
|
|
7551
|
-
const [isOpenAiAvailable, setIsOpenAiAvailable] = (0,
|
|
7600
|
+
const [isOpenAiAvailable, setIsOpenAiAvailable] = (0, import_react4.useState)(
|
|
7552
7601
|
() => typeof window !== "undefined" && !!window.openai
|
|
7553
7602
|
);
|
|
7554
|
-
(0,
|
|
7603
|
+
(0, import_react4.useEffect)(() => {
|
|
7555
7604
|
if (typeof window !== "undefined" && window.openai) {
|
|
7556
7605
|
setIsOpenAiAvailable(true);
|
|
7557
7606
|
return;
|
|
@@ -7585,11 +7634,12 @@ function useWidget(defaultProps) {
|
|
|
7585
7634
|
}
|
|
7586
7635
|
};
|
|
7587
7636
|
}, []);
|
|
7588
|
-
const provider = (0,
|
|
7637
|
+
const provider = (0, import_react4.useMemo)(() => {
|
|
7589
7638
|
return isOpenAiAvailable ? "openai" : "mcp-ui";
|
|
7590
7639
|
}, [isOpenAiAvailable]);
|
|
7591
|
-
const
|
|
7592
|
-
|
|
7640
|
+
const searchString = typeof window !== "undefined" ? window.location.search : "";
|
|
7641
|
+
const urlParams = (0, import_react4.useMemo)(() => {
|
|
7642
|
+
const urlParams2 = new URLSearchParams(searchString);
|
|
7593
7643
|
if (urlParams2.has("mcpUseParams")) {
|
|
7594
7644
|
return JSON.parse(urlParams2.get("mcpUseParams"));
|
|
7595
7645
|
}
|
|
@@ -7598,7 +7648,7 @@ function useWidget(defaultProps) {
|
|
|
7598
7648
|
toolOutput: {},
|
|
7599
7649
|
toolId: ""
|
|
7600
7650
|
};
|
|
7601
|
-
}, [
|
|
7651
|
+
}, [searchString]);
|
|
7602
7652
|
const toolInput = provider === "openai" ? useOpenAiGlobal("toolInput") : urlParams.toolInput;
|
|
7603
7653
|
const toolOutput = provider === "openai" ? useOpenAiGlobal("toolOutput") : urlParams.toolOutput;
|
|
7604
7654
|
const toolResponseMetadata = useOpenAiGlobal("toolResponseMetadata");
|
|
@@ -7609,13 +7659,19 @@ function useWidget(defaultProps) {
|
|
|
7609
7659
|
const maxHeight = useOpenAiGlobal("maxHeight");
|
|
7610
7660
|
const userAgent = useOpenAiGlobal("userAgent");
|
|
7611
7661
|
const locale = useOpenAiGlobal("locale");
|
|
7612
|
-
const
|
|
7613
|
-
|
|
7662
|
+
const mcp_url = (0, import_react4.useMemo)(() => {
|
|
7663
|
+
if (typeof window !== "undefined" && window.__mcpPublicUrl) {
|
|
7664
|
+
return window.__mcpPublicUrl.replace(/\/mcp-use\/public$/, "");
|
|
7665
|
+
}
|
|
7666
|
+
return "";
|
|
7667
|
+
}, []);
|
|
7668
|
+
const [localWidgetState, setLocalWidgetState] = (0, import_react4.useState)(null);
|
|
7669
|
+
(0, import_react4.useEffect)(() => {
|
|
7614
7670
|
if (widgetState !== void 0) {
|
|
7615
7671
|
setLocalWidgetState(widgetState);
|
|
7616
7672
|
}
|
|
7617
7673
|
}, [widgetState]);
|
|
7618
|
-
const callTool = (0,
|
|
7674
|
+
const callTool = (0, import_react4.useCallback)(
|
|
7619
7675
|
async (name, args) => {
|
|
7620
7676
|
if (!window.openai?.callTool) {
|
|
7621
7677
|
throw new Error("window.openai.callTool is not available");
|
|
@@ -7624,7 +7680,7 @@ function useWidget(defaultProps) {
|
|
|
7624
7680
|
},
|
|
7625
7681
|
[]
|
|
7626
7682
|
);
|
|
7627
|
-
const sendFollowUpMessage = (0,
|
|
7683
|
+
const sendFollowUpMessage = (0, import_react4.useCallback)(
|
|
7628
7684
|
async (prompt) => {
|
|
7629
7685
|
if (!window.openai?.sendFollowUpMessage) {
|
|
7630
7686
|
throw new Error("window.openai.sendFollowUpMessage is not available");
|
|
@@ -7633,13 +7689,13 @@ function useWidget(defaultProps) {
|
|
|
7633
7689
|
},
|
|
7634
7690
|
[]
|
|
7635
7691
|
);
|
|
7636
|
-
const openExternal = (0,
|
|
7692
|
+
const openExternal = (0, import_react4.useCallback)((href) => {
|
|
7637
7693
|
if (!window.openai?.openExternal) {
|
|
7638
7694
|
throw new Error("window.openai.openExternal is not available");
|
|
7639
7695
|
}
|
|
7640
7696
|
window.openai.openExternal({ href });
|
|
7641
7697
|
}, []);
|
|
7642
|
-
const requestDisplayMode = (0,
|
|
7698
|
+
const requestDisplayMode = (0, import_react4.useCallback)(
|
|
7643
7699
|
async (mode) => {
|
|
7644
7700
|
if (!window.openai?.requestDisplayMode) {
|
|
7645
7701
|
throw new Error("window.openai.requestDisplayMode is not available");
|
|
@@ -7648,16 +7704,17 @@ function useWidget(defaultProps) {
|
|
|
7648
7704
|
},
|
|
7649
7705
|
[]
|
|
7650
7706
|
);
|
|
7651
|
-
const setState = (0,
|
|
7707
|
+
const setState = (0, import_react4.useCallback)(
|
|
7652
7708
|
async (state) => {
|
|
7653
|
-
const newState = typeof state === "function" ? state(localWidgetState) : state;
|
|
7654
7709
|
if (!window.openai?.setWidgetState) {
|
|
7655
7710
|
throw new Error("window.openai.setWidgetState is not available");
|
|
7656
7711
|
}
|
|
7712
|
+
const currentState = widgetState !== void 0 ? widgetState : localWidgetState;
|
|
7713
|
+
const newState = typeof state === "function" ? state(currentState) : state;
|
|
7657
7714
|
setLocalWidgetState(newState);
|
|
7658
7715
|
return window.openai.setWidgetState(newState);
|
|
7659
7716
|
},
|
|
7660
|
-
[localWidgetState]
|
|
7717
|
+
[widgetState, localWidgetState]
|
|
7661
7718
|
);
|
|
7662
7719
|
return {
|
|
7663
7720
|
// Props and state (with defaults)
|
|
@@ -7676,6 +7733,7 @@ function useWidget(defaultProps) {
|
|
|
7676
7733
|
capabilities: { hover: true, touch: false }
|
|
7677
7734
|
},
|
|
7678
7735
|
locale: locale || "en",
|
|
7736
|
+
mcp_url,
|
|
7679
7737
|
// Actions
|
|
7680
7738
|
callTool,
|
|
7681
7739
|
sendFollowUpMessage,
|
|
@@ -7698,7 +7756,7 @@ function useWidgetTheme() {
|
|
|
7698
7756
|
__name(useWidgetTheme, "useWidgetTheme");
|
|
7699
7757
|
function useWidgetState(defaultState) {
|
|
7700
7758
|
const { state, setState } = useWidget();
|
|
7701
|
-
(0,
|
|
7759
|
+
(0, import_react4.useEffect)(() => {
|
|
7702
7760
|
if (state === null && defaultState !== void 0 && window.openai?.setWidgetState) {
|
|
7703
7761
|
setState(defaultState);
|
|
7704
7762
|
}
|
|
@@ -7707,283 +7765,49 @@ function useWidgetState(defaultState) {
|
|
|
7707
7765
|
}
|
|
7708
7766
|
__name(useWidgetState, "useWidgetState");
|
|
7709
7767
|
|
|
7710
|
-
// src/react/
|
|
7711
|
-
var
|
|
7712
|
-
|
|
7713
|
-
|
|
7714
|
-
|
|
7715
|
-
|
|
7716
|
-
|
|
7717
|
-
|
|
7718
|
-
|
|
7719
|
-
|
|
7720
|
-
const [isHovered, setIsHovered] = (0, import_react3.useState)(false);
|
|
7721
|
-
const containerRef = (0, import_react3.useRef)(null);
|
|
7722
|
-
const isFullscreen = displayMode === "fullscreen" && isAvailable;
|
|
7723
|
-
const isPip = displayMode === "pip" && isAvailable;
|
|
7724
|
-
const isDark = theme === "dark";
|
|
7725
|
-
const buttonBg = isDark ? "rgba(255, 255, 255, 0.1)" : "rgba(0, 0, 0, 0.7)";
|
|
7726
|
-
const buttonBgHover = isDark ? "rgba(255, 255, 255, 0.2)" : "rgba(0, 0, 0, 0.9)";
|
|
7727
|
-
const buttonColor = "white";
|
|
7728
|
-
const getPositionStyles = /* @__PURE__ */ __name(() => {
|
|
7729
|
-
const baseOffset = 16;
|
|
7730
|
-
const topOffset = safeArea?.insets?.top ? `${Math.max(baseOffset, safeArea.insets.top + 8)}px` : `${baseOffset}px`;
|
|
7731
|
-
const rightOffset = safeArea?.insets?.right ? `${Math.max(baseOffset, safeArea.insets.right + 8)}px` : `${baseOffset}px`;
|
|
7732
|
-
const bottomOffset = safeArea?.insets?.bottom ? `${Math.max(baseOffset, safeArea.insets.bottom + 8)}px` : `${baseOffset}px`;
|
|
7733
|
-
const leftOffset = safeArea?.insets?.left ? `${Math.max(baseOffset, safeArea.insets.left + 8)}px` : `${baseOffset}px`;
|
|
7734
|
-
const styles = {
|
|
7735
|
-
position: "absolute",
|
|
7736
|
-
zIndex: 1e3,
|
|
7737
|
-
display: "flex",
|
|
7738
|
-
gap: "8px",
|
|
7739
|
-
opacity: isHovered ? 1 : 0,
|
|
7740
|
-
transition: "opacity 0.2s ease-in-out",
|
|
7741
|
-
pointerEvents: isHovered ? "auto" : "none"
|
|
7742
|
-
};
|
|
7743
|
-
switch (position) {
|
|
7744
|
-
case "top-left":
|
|
7745
|
-
styles.top = topOffset;
|
|
7746
|
-
styles.left = leftOffset;
|
|
7747
|
-
break;
|
|
7748
|
-
case "top-center":
|
|
7749
|
-
styles.top = topOffset;
|
|
7750
|
-
styles.left = "50%";
|
|
7751
|
-
styles.transform = "translateX(-50%)";
|
|
7752
|
-
break;
|
|
7753
|
-
case "top-right":
|
|
7754
|
-
styles.top = topOffset;
|
|
7755
|
-
styles.right = rightOffset;
|
|
7756
|
-
break;
|
|
7757
|
-
case "center-left":
|
|
7758
|
-
styles.top = "50%";
|
|
7759
|
-
styles.left = leftOffset;
|
|
7760
|
-
styles.transform = "translateY(-50%)";
|
|
7761
|
-
break;
|
|
7762
|
-
case "center-right":
|
|
7763
|
-
styles.top = "50%";
|
|
7764
|
-
styles.right = rightOffset;
|
|
7765
|
-
styles.transform = "translateY(-50%)";
|
|
7766
|
-
break;
|
|
7767
|
-
case "bottom-left":
|
|
7768
|
-
styles.bottom = bottomOffset;
|
|
7769
|
-
styles.left = leftOffset;
|
|
7770
|
-
break;
|
|
7771
|
-
case "bottom-center":
|
|
7772
|
-
styles.bottom = bottomOffset;
|
|
7773
|
-
styles.left = "50%";
|
|
7774
|
-
styles.transform = "translateX(-50%)";
|
|
7775
|
-
break;
|
|
7776
|
-
case "bottom-right":
|
|
7777
|
-
styles.bottom = bottomOffset;
|
|
7778
|
-
styles.right = rightOffset;
|
|
7779
|
-
break;
|
|
7780
|
-
default:
|
|
7781
|
-
styles.top = topOffset;
|
|
7782
|
-
styles.right = rightOffset;
|
|
7783
|
-
break;
|
|
7784
|
-
}
|
|
7785
|
-
return styles;
|
|
7786
|
-
}, "getPositionStyles");
|
|
7787
|
-
(0, import_react3.useEffect)(() => {
|
|
7788
|
-
if (!attachTo) return;
|
|
7789
|
-
const handleMouseEnter = /* @__PURE__ */ __name(() => setIsHovered(true), "handleMouseEnter");
|
|
7790
|
-
const handleMouseLeave = /* @__PURE__ */ __name(() => setIsHovered(false), "handleMouseLeave");
|
|
7791
|
-
attachTo.addEventListener("mouseenter", handleMouseEnter);
|
|
7792
|
-
attachTo.addEventListener("mouseleave", handleMouseLeave);
|
|
7793
|
-
return () => {
|
|
7794
|
-
attachTo.removeEventListener("mouseenter", handleMouseEnter);
|
|
7795
|
-
attachTo.removeEventListener("mouseleave", handleMouseLeave);
|
|
7796
|
-
};
|
|
7797
|
-
}, [attachTo]);
|
|
7798
|
-
const handleFullscreen = /* @__PURE__ */ __name(async () => {
|
|
7799
|
-
try {
|
|
7800
|
-
await requestDisplayMode("fullscreen");
|
|
7801
|
-
} catch (error) {
|
|
7802
|
-
console.error("Failed to go fullscreen:", error);
|
|
7803
|
-
}
|
|
7804
|
-
}, "handleFullscreen");
|
|
7805
|
-
const handlePip = /* @__PURE__ */ __name(async () => {
|
|
7806
|
-
try {
|
|
7807
|
-
await requestDisplayMode("pip");
|
|
7808
|
-
} catch (error) {
|
|
7809
|
-
console.error("Failed to go pip:", error);
|
|
7810
|
-
}
|
|
7811
|
-
}, "handlePip");
|
|
7812
|
-
const getTooltipStyles = /* @__PURE__ */ __name(() => {
|
|
7813
|
-
const baseStyles = {
|
|
7814
|
-
position: "absolute",
|
|
7815
|
-
padding: "4px 8px",
|
|
7816
|
-
backgroundColor: isDark ? "rgba(0, 0, 0, 0.9)" : "rgba(0, 0, 0, 0.9)",
|
|
7817
|
-
color: "white",
|
|
7818
|
-
borderRadius: "4px",
|
|
7819
|
-
fontSize: "12px",
|
|
7820
|
-
whiteSpace: "nowrap",
|
|
7821
|
-
pointerEvents: "none",
|
|
7822
|
-
transition: "opacity 0.2s ease-in-out"
|
|
7823
|
-
};
|
|
7824
|
-
switch (position) {
|
|
7825
|
-
case "top-right":
|
|
7826
|
-
return {
|
|
7827
|
-
...baseStyles,
|
|
7828
|
-
top: "100%",
|
|
7829
|
-
right: "0",
|
|
7830
|
-
marginTop: "8px"
|
|
7831
|
-
};
|
|
7832
|
-
case "top-left":
|
|
7833
|
-
return {
|
|
7834
|
-
...baseStyles,
|
|
7835
|
-
top: "100%",
|
|
7836
|
-
left: "0",
|
|
7837
|
-
marginTop: "8px"
|
|
7838
|
-
};
|
|
7839
|
-
case "top-center":
|
|
7840
|
-
return {
|
|
7841
|
-
...baseStyles,
|
|
7842
|
-
top: "100%",
|
|
7843
|
-
left: "50%",
|
|
7844
|
-
transform: "translateX(-50%)",
|
|
7845
|
-
marginTop: "8px"
|
|
7846
|
-
};
|
|
7847
|
-
case "bottom-right":
|
|
7848
|
-
return {
|
|
7849
|
-
...baseStyles,
|
|
7850
|
-
bottom: "100%",
|
|
7851
|
-
right: "0",
|
|
7852
|
-
marginBottom: "8px"
|
|
7853
|
-
};
|
|
7854
|
-
case "bottom-left":
|
|
7855
|
-
return {
|
|
7856
|
-
...baseStyles,
|
|
7857
|
-
bottom: "100%",
|
|
7858
|
-
left: "0",
|
|
7859
|
-
marginBottom: "8px"
|
|
7860
|
-
};
|
|
7861
|
-
case "bottom-center":
|
|
7862
|
-
return {
|
|
7863
|
-
...baseStyles,
|
|
7864
|
-
bottom: "100%",
|
|
7865
|
-
left: "50%",
|
|
7866
|
-
transform: "translateX(-50%)",
|
|
7867
|
-
marginBottom: "8px"
|
|
7868
|
-
};
|
|
7869
|
-
case "center-left":
|
|
7870
|
-
return {
|
|
7871
|
-
...baseStyles,
|
|
7872
|
-
left: "100%",
|
|
7873
|
-
top: "50%",
|
|
7874
|
-
transform: "translateY(-50%)",
|
|
7875
|
-
marginLeft: "8px"
|
|
7876
|
-
};
|
|
7877
|
-
case "center-right":
|
|
7878
|
-
return {
|
|
7879
|
-
...baseStyles,
|
|
7880
|
-
right: "100%",
|
|
7881
|
-
top: "50%",
|
|
7882
|
-
transform: "translateY(-50%)",
|
|
7883
|
-
marginRight: "8px"
|
|
7884
|
-
};
|
|
7885
|
-
default:
|
|
7886
|
-
return {
|
|
7887
|
-
...baseStyles,
|
|
7888
|
-
top: "100%",
|
|
7889
|
-
right: "0",
|
|
7890
|
-
marginTop: "8px"
|
|
7891
|
-
};
|
|
7768
|
+
// src/react/ThemeProvider.tsx
|
|
7769
|
+
var ThemeProvider = /* @__PURE__ */ __name(({
|
|
7770
|
+
children
|
|
7771
|
+
}) => {
|
|
7772
|
+
const { theme, isAvailable } = useWidget();
|
|
7773
|
+
console.log("theme", theme);
|
|
7774
|
+
const [systemPreference, setSystemPreference] = (0, import_react5.useState)(
|
|
7775
|
+
() => {
|
|
7776
|
+
if (typeof window === "undefined") return "light";
|
|
7777
|
+
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
7892
7778
|
}
|
|
7893
|
-
}, "getTooltipStyles");
|
|
7894
|
-
const IconButton = /* @__PURE__ */ __name(({
|
|
7895
|
-
onClick,
|
|
7896
|
-
label,
|
|
7897
|
-
children: icon
|
|
7898
|
-
}) => {
|
|
7899
|
-
const [isButtonHovered, setIsButtonHovered] = (0, import_react3.useState)(false);
|
|
7900
|
-
const tooltipStyles = getTooltipStyles();
|
|
7901
|
-
return /* @__PURE__ */ import_react3.default.createElement(
|
|
7902
|
-
"button",
|
|
7903
|
-
{
|
|
7904
|
-
style: {
|
|
7905
|
-
padding: "8px",
|
|
7906
|
-
backgroundColor: buttonBg,
|
|
7907
|
-
color: buttonColor,
|
|
7908
|
-
border: "none",
|
|
7909
|
-
borderRadius: "8px",
|
|
7910
|
-
cursor: "pointer",
|
|
7911
|
-
display: "flex",
|
|
7912
|
-
alignItems: "center",
|
|
7913
|
-
justifyContent: "center",
|
|
7914
|
-
width: "32px",
|
|
7915
|
-
height: "32px",
|
|
7916
|
-
transition: "background-color 0.2s",
|
|
7917
|
-
backdropFilter: "blur(8px)",
|
|
7918
|
-
WebkitBackdropFilter: "blur(8px)",
|
|
7919
|
-
boxShadow: isDark ? "0 2px 8px rgba(0, 0, 0, 0.3)" : "0 2px 8px rgba(0, 0, 0, 0.2)",
|
|
7920
|
-
position: "relative"
|
|
7921
|
-
},
|
|
7922
|
-
onMouseEnter: (e) => {
|
|
7923
|
-
e.currentTarget.style.backgroundColor = buttonBgHover;
|
|
7924
|
-
setIsButtonHovered(true);
|
|
7925
|
-
},
|
|
7926
|
-
onMouseLeave: (e) => {
|
|
7927
|
-
e.currentTarget.style.backgroundColor = buttonBg;
|
|
7928
|
-
setIsButtonHovered(false);
|
|
7929
|
-
},
|
|
7930
|
-
onClick,
|
|
7931
|
-
"aria-label": label
|
|
7932
|
-
},
|
|
7933
|
-
/* @__PURE__ */ import_react3.default.createElement(
|
|
7934
|
-
"svg",
|
|
7935
|
-
{
|
|
7936
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
7937
|
-
width: "16",
|
|
7938
|
-
height: "16",
|
|
7939
|
-
viewBox: "0 0 24 24",
|
|
7940
|
-
fill: "none",
|
|
7941
|
-
stroke: "currentColor",
|
|
7942
|
-
strokeWidth: "2",
|
|
7943
|
-
strokeLinecap: "round",
|
|
7944
|
-
strokeLinejoin: "round",
|
|
7945
|
-
style: { display: "block" }
|
|
7946
|
-
},
|
|
7947
|
-
icon
|
|
7948
|
-
),
|
|
7949
|
-
showLabels && /* @__PURE__ */ import_react3.default.createElement(
|
|
7950
|
-
"span",
|
|
7951
|
-
{
|
|
7952
|
-
style: {
|
|
7953
|
-
...tooltipStyles,
|
|
7954
|
-
opacity: isButtonHovered ? 1 : 0
|
|
7955
|
-
}
|
|
7956
|
-
},
|
|
7957
|
-
label
|
|
7958
|
-
)
|
|
7959
|
-
);
|
|
7960
|
-
}, "IconButton");
|
|
7961
|
-
return /* @__PURE__ */ import_react3.default.createElement(
|
|
7962
|
-
"div",
|
|
7963
|
-
{
|
|
7964
|
-
ref: containerRef,
|
|
7965
|
-
className,
|
|
7966
|
-
style: {
|
|
7967
|
-
position: "relative",
|
|
7968
|
-
height: "fit-content"
|
|
7969
|
-
},
|
|
7970
|
-
onMouseEnter: () => !attachTo && setIsHovered(true),
|
|
7971
|
-
onMouseLeave: () => !attachTo && setIsHovered(false)
|
|
7972
|
-
},
|
|
7973
|
-
!isFullscreen && !isPip && /* @__PURE__ */ import_react3.default.createElement("div", { style: getPositionStyles() }, /* @__PURE__ */ import_react3.default.createElement(IconButton, { onClick: handleFullscreen, label: "Fullscreen" }, /* @__PURE__ */ import_react3.default.createElement("path", { d: "M15 3h6v6" }), /* @__PURE__ */ import_react3.default.createElement("path", { d: "m21 3-7 7" }), /* @__PURE__ */ import_react3.default.createElement("path", { d: "m3 21 7-7" }), /* @__PURE__ */ import_react3.default.createElement("path", { d: "M9 21H3v-6" })), /* @__PURE__ */ import_react3.default.createElement(IconButton, { onClick: handlePip, label: "Picture in Picture" }, /* @__PURE__ */ import_react3.default.createElement("path", { d: "M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4" }), /* @__PURE__ */ import_react3.default.createElement("rect", { width: "10", height: "7", x: "12", y: "13", rx: "2" }))),
|
|
7974
|
-
children
|
|
7975
7779
|
);
|
|
7976
|
-
|
|
7977
|
-
|
|
7780
|
+
(0, import_react5.useEffect)(() => {
|
|
7781
|
+
if (typeof window === "undefined") return;
|
|
7782
|
+
const mediaQuery = window.matchMedia("(prefers-color-scheme: dark)");
|
|
7783
|
+
const handleChange = /* @__PURE__ */ __name((e) => {
|
|
7784
|
+
setSystemPreference(e.matches ? "dark" : "light");
|
|
7785
|
+
}, "handleChange");
|
|
7786
|
+
mediaQuery.addEventListener("change", handleChange);
|
|
7787
|
+
return () => mediaQuery.removeEventListener("change", handleChange);
|
|
7788
|
+
}, []);
|
|
7789
|
+
const effectiveTheme = isAvailable ? theme : systemPreference;
|
|
7790
|
+
(0, import_react5.useLayoutEffect)(() => {
|
|
7791
|
+
if (typeof document === "undefined") return;
|
|
7792
|
+
if (effectiveTheme === "dark") {
|
|
7793
|
+
document.documentElement.classList.add("dark");
|
|
7794
|
+
} else {
|
|
7795
|
+
document.documentElement.classList.remove("dark");
|
|
7796
|
+
}
|
|
7797
|
+
}, [effectiveTheme]);
|
|
7798
|
+
return /* @__PURE__ */ import_react5.default.createElement(import_react5.default.Fragment, null, children);
|
|
7799
|
+
}, "ThemeProvider");
|
|
7978
7800
|
|
|
7979
|
-
// src/react/
|
|
7980
|
-
var
|
|
7981
|
-
function
|
|
7801
|
+
// src/react/WidgetControls.tsx
|
|
7802
|
+
var import_react6 = __toESM(require("react"), 1);
|
|
7803
|
+
function WidgetControls({
|
|
7982
7804
|
children,
|
|
7983
7805
|
className = "",
|
|
7984
7806
|
position = "top-right",
|
|
7985
7807
|
attachTo,
|
|
7986
|
-
showLabels = true
|
|
7808
|
+
showLabels = true,
|
|
7809
|
+
debugger: enableDebugger = false,
|
|
7810
|
+
viewControls = false
|
|
7987
7811
|
}) {
|
|
7988
7812
|
const {
|
|
7989
7813
|
props,
|
|
@@ -8003,23 +7827,24 @@ function WidgetDebugger({
|
|
|
8003
7827
|
requestDisplayMode,
|
|
8004
7828
|
setState
|
|
8005
7829
|
} = useWidget();
|
|
8006
|
-
const [isHovered, setIsHovered] = (0,
|
|
8007
|
-
const [isOverlayOpen, setIsOverlayOpen] = (0,
|
|
8008
|
-
const containerRef = (0,
|
|
8009
|
-
const overlayRef = (0,
|
|
8010
|
-
const [windowOpenAiKeys, setWindowOpenAiKeys] = (0,
|
|
8011
|
-
const [actionResult, setActionResult] = (0,
|
|
8012
|
-
const [toolName, setToolName] = (0,
|
|
8013
|
-
const [toolArgs, setToolArgs] = (0,
|
|
8014
|
-
const [followUpMessage, setFollowUpMessage] = (0,
|
|
7830
|
+
const [isHovered, setIsHovered] = (0, import_react6.useState)(false);
|
|
7831
|
+
const [isOverlayOpen, setIsOverlayOpen] = (0, import_react6.useState)(false);
|
|
7832
|
+
const containerRef = (0, import_react6.useRef)(null);
|
|
7833
|
+
const overlayRef = (0, import_react6.useRef)(null);
|
|
7834
|
+
const [windowOpenAiKeys, setWindowOpenAiKeys] = (0, import_react6.useState)([]);
|
|
7835
|
+
const [actionResult, setActionResult] = (0, import_react6.useState)("");
|
|
7836
|
+
const [toolName, setToolName] = (0, import_react6.useState)("get-my-city");
|
|
7837
|
+
const [toolArgs, setToolArgs] = (0, import_react6.useState)("{}");
|
|
7838
|
+
const [followUpMessage, setFollowUpMessage] = (0, import_react6.useState)(
|
|
8015
7839
|
"Test follow-up message"
|
|
8016
7840
|
);
|
|
8017
|
-
const [externalUrl, setExternalUrl] = (0,
|
|
7841
|
+
const [externalUrl, setExternalUrl] = (0, import_react6.useState)(
|
|
8018
7842
|
"https://docs.mcp-use.com"
|
|
8019
7843
|
);
|
|
8020
7844
|
const isFullscreen = displayMode === "fullscreen" && isAvailable;
|
|
8021
7845
|
const isPip = displayMode === "pip" && isAvailable;
|
|
8022
|
-
|
|
7846
|
+
const isDevMode = typeof window !== "undefined" && window.location.pathname.includes("/inspector/api/dev-widget/");
|
|
7847
|
+
(0, import_react6.useEffect)(() => {
|
|
8023
7848
|
const timeoutId = setTimeout(() => {
|
|
8024
7849
|
if (typeof window !== "undefined" && window.openai) {
|
|
8025
7850
|
try {
|
|
@@ -8032,75 +7857,88 @@ function WidgetDebugger({
|
|
|
8032
7857
|
setWindowOpenAiKeys([]);
|
|
8033
7858
|
}
|
|
8034
7859
|
}, 100);
|
|
8035
|
-
return () =>
|
|
7860
|
+
return () => {
|
|
7861
|
+
clearTimeout(timeoutId);
|
|
7862
|
+
};
|
|
8036
7863
|
}, []);
|
|
8037
7864
|
const isDark = theme === "dark";
|
|
8038
|
-
const
|
|
8039
|
-
|
|
8040
|
-
|
|
8041
|
-
|
|
7865
|
+
const getPositionClasses = /* @__PURE__ */ __name(() => {
|
|
7866
|
+
const baseClasses = [
|
|
7867
|
+
"absolute",
|
|
7868
|
+
"z-[1000]",
|
|
7869
|
+
"flex",
|
|
7870
|
+
"gap-2",
|
|
7871
|
+
"transition-opacity",
|
|
7872
|
+
"duration-200",
|
|
7873
|
+
"ease-in-out",
|
|
7874
|
+
isHovered ? "opacity-100" : "opacity-0",
|
|
7875
|
+
isHovered ? "pointer-events-auto" : "pointer-events-none"
|
|
7876
|
+
];
|
|
7877
|
+
switch (position) {
|
|
7878
|
+
case "top-left":
|
|
7879
|
+
return [...baseClasses, "top-4", "left-4"];
|
|
7880
|
+
case "top-center":
|
|
7881
|
+
return [...baseClasses, "top-4", "left-1/2", "-translate-x-1/2"];
|
|
7882
|
+
case "top-right":
|
|
7883
|
+
return [...baseClasses, "top-4", "right-4"];
|
|
7884
|
+
case "center-left":
|
|
7885
|
+
return [...baseClasses, "top-1/2", "left-4", "-translate-y-1/2"];
|
|
7886
|
+
case "center-right":
|
|
7887
|
+
return [...baseClasses, "top-1/2", "right-4", "-translate-y-1/2"];
|
|
7888
|
+
case "bottom-left":
|
|
7889
|
+
return [...baseClasses, "bottom-4", "left-4"];
|
|
7890
|
+
case "bottom-center":
|
|
7891
|
+
return [...baseClasses, "bottom-4", "left-1/2", "-translate-x-1/2"];
|
|
7892
|
+
case "bottom-right":
|
|
7893
|
+
return [...baseClasses, "bottom-4", "right-4"];
|
|
7894
|
+
default:
|
|
7895
|
+
return [...baseClasses, "top-4", "right-4"];
|
|
7896
|
+
}
|
|
7897
|
+
}, "getPositionClasses");
|
|
7898
|
+
const getPositionOffsetStyles = /* @__PURE__ */ __name(() => {
|
|
8042
7899
|
const baseOffset = 16;
|
|
8043
|
-
const topOffset = safeArea?.insets?.top ?
|
|
8044
|
-
const rightOffset = safeArea?.insets?.right ?
|
|
8045
|
-
const bottomOffset = safeArea?.insets?.bottom ?
|
|
8046
|
-
const leftOffset = safeArea?.insets?.left ?
|
|
8047
|
-
const styles = {
|
|
8048
|
-
position: "absolute",
|
|
8049
|
-
zIndex: 1e3,
|
|
8050
|
-
display: "flex",
|
|
8051
|
-
gap: "8px",
|
|
8052
|
-
opacity: isHovered ? 1 : 0,
|
|
8053
|
-
transition: "opacity 0.2s ease-in-out",
|
|
8054
|
-
pointerEvents: isHovered ? "auto" : "none"
|
|
8055
|
-
};
|
|
7900
|
+
const topOffset = safeArea?.insets?.top ? Math.max(baseOffset, safeArea.insets.top + 8) : baseOffset;
|
|
7901
|
+
const rightOffset = safeArea?.insets?.right ? Math.max(baseOffset, safeArea.insets.right + 8) : baseOffset;
|
|
7902
|
+
const bottomOffset = safeArea?.insets?.bottom ? Math.max(baseOffset, safeArea.insets.bottom + 8) : baseOffset;
|
|
7903
|
+
const leftOffset = safeArea?.insets?.left ? Math.max(baseOffset, safeArea.insets.left + 8) : baseOffset;
|
|
7904
|
+
const styles = {};
|
|
8056
7905
|
switch (position) {
|
|
8057
7906
|
case "top-left":
|
|
8058
|
-
styles.top = topOffset
|
|
8059
|
-
styles.left = leftOffset
|
|
7907
|
+
styles.top = `${topOffset}px`;
|
|
7908
|
+
styles.left = `${leftOffset}px`;
|
|
8060
7909
|
break;
|
|
8061
7910
|
case "top-center":
|
|
8062
|
-
styles.top = topOffset
|
|
8063
|
-
styles.left = "50%";
|
|
8064
|
-
styles.transform = "translateX(-50%)";
|
|
7911
|
+
styles.top = `${topOffset}px`;
|
|
8065
7912
|
break;
|
|
8066
7913
|
case "top-right":
|
|
8067
|
-
styles.top = topOffset
|
|
8068
|
-
styles.right = rightOffset
|
|
8069
|
-
if (!isFullscreen && !isPip) {
|
|
8070
|
-
styles.right = `calc(${rightOffset} + 80px)`;
|
|
8071
|
-
}
|
|
7914
|
+
styles.top = `${topOffset}px`;
|
|
7915
|
+
styles.right = `${rightOffset}px`;
|
|
8072
7916
|
break;
|
|
8073
7917
|
case "center-left":
|
|
8074
|
-
styles.
|
|
8075
|
-
styles.left = leftOffset;
|
|
8076
|
-
styles.transform = "translateY(-50%)";
|
|
7918
|
+
styles.left = `${leftOffset}px`;
|
|
8077
7919
|
break;
|
|
8078
7920
|
case "center-right":
|
|
8079
|
-
styles.
|
|
8080
|
-
styles.right = rightOffset;
|
|
8081
|
-
styles.transform = "translateY(-50%)";
|
|
7921
|
+
styles.right = `${rightOffset}px`;
|
|
8082
7922
|
break;
|
|
8083
7923
|
case "bottom-left":
|
|
8084
|
-
styles.bottom = bottomOffset
|
|
8085
|
-
styles.left = leftOffset
|
|
7924
|
+
styles.bottom = `${bottomOffset}px`;
|
|
7925
|
+
styles.left = `${leftOffset}px`;
|
|
8086
7926
|
break;
|
|
8087
7927
|
case "bottom-center":
|
|
8088
|
-
styles.bottom = bottomOffset
|
|
8089
|
-
styles.left = "50%";
|
|
8090
|
-
styles.transform = "translateX(-50%)";
|
|
7928
|
+
styles.bottom = `${bottomOffset}px`;
|
|
8091
7929
|
break;
|
|
8092
7930
|
case "bottom-right":
|
|
8093
|
-
styles.bottom = bottomOffset
|
|
8094
|
-
styles.right = rightOffset
|
|
7931
|
+
styles.bottom = `${bottomOffset}px`;
|
|
7932
|
+
styles.right = `${rightOffset}px`;
|
|
8095
7933
|
break;
|
|
8096
7934
|
default:
|
|
8097
|
-
styles.top = topOffset
|
|
8098
|
-
styles.right = rightOffset
|
|
7935
|
+
styles.top = `${topOffset}px`;
|
|
7936
|
+
styles.right = `${rightOffset}px`;
|
|
8099
7937
|
break;
|
|
8100
7938
|
}
|
|
8101
7939
|
return styles;
|
|
8102
|
-
}, "
|
|
8103
|
-
(0,
|
|
7940
|
+
}, "getPositionOffsetStyles");
|
|
7941
|
+
(0, import_react6.useEffect)(() => {
|
|
8104
7942
|
if (!attachTo) return;
|
|
8105
7943
|
const handleMouseEnter = /* @__PURE__ */ __name(() => setIsHovered(true), "handleMouseEnter");
|
|
8106
7944
|
const handleMouseLeave = /* @__PURE__ */ __name(() => setIsHovered(false), "handleMouseLeave");
|
|
@@ -8111,7 +7949,7 @@ function WidgetDebugger({
|
|
|
8111
7949
|
attachTo.removeEventListener("mouseleave", handleMouseLeave);
|
|
8112
7950
|
};
|
|
8113
7951
|
}, [attachTo]);
|
|
8114
|
-
(0,
|
|
7952
|
+
(0, import_react6.useEffect)(() => {
|
|
8115
7953
|
if (!isOverlayOpen) return;
|
|
8116
7954
|
const handleClickOutside = /* @__PURE__ */ __name((event) => {
|
|
8117
7955
|
if (overlayRef.current && !overlayRef.current.contains(event.target)) {
|
|
@@ -8123,7 +7961,7 @@ function WidgetDebugger({
|
|
|
8123
7961
|
document.removeEventListener("mousedown", handleClickOutside);
|
|
8124
7962
|
};
|
|
8125
7963
|
}, [isOverlayOpen]);
|
|
8126
|
-
(0,
|
|
7964
|
+
(0, import_react6.useEffect)(() => {
|
|
8127
7965
|
if (isOverlayOpen) {
|
|
8128
7966
|
document.body.style.overflow = "hidden";
|
|
8129
7967
|
} else {
|
|
@@ -8182,128 +8020,97 @@ function WidgetDebugger({
|
|
|
8182
8020
|
setActionResult(`Error: ${error.message}`);
|
|
8183
8021
|
}
|
|
8184
8022
|
}, "handleSetState");
|
|
8185
|
-
const
|
|
8186
|
-
|
|
8187
|
-
|
|
8188
|
-
|
|
8189
|
-
|
|
8190
|
-
|
|
8191
|
-
|
|
8192
|
-
|
|
8193
|
-
|
|
8194
|
-
|
|
8195
|
-
|
|
8196
|
-
|
|
8023
|
+
const handleFullscreen = /* @__PURE__ */ __name(async () => {
|
|
8024
|
+
try {
|
|
8025
|
+
await requestDisplayMode("fullscreen");
|
|
8026
|
+
} catch (error) {
|
|
8027
|
+
console.error("Failed to go fullscreen:", error);
|
|
8028
|
+
}
|
|
8029
|
+
}, "handleFullscreen");
|
|
8030
|
+
const handlePip = /* @__PURE__ */ __name(async () => {
|
|
8031
|
+
try {
|
|
8032
|
+
await requestDisplayMode("pip");
|
|
8033
|
+
} catch (error) {
|
|
8034
|
+
console.error("Failed to go pip:", error);
|
|
8035
|
+
}
|
|
8036
|
+
}, "handlePip");
|
|
8037
|
+
const getTooltipClasses = /* @__PURE__ */ __name(() => {
|
|
8038
|
+
const baseClasses = [
|
|
8039
|
+
"absolute",
|
|
8040
|
+
"px-2",
|
|
8041
|
+
"py-1",
|
|
8042
|
+
"bg-black/90",
|
|
8043
|
+
"text-white",
|
|
8044
|
+
"rounded",
|
|
8045
|
+
"text-xs",
|
|
8046
|
+
"whitespace-nowrap",
|
|
8047
|
+
"pointer-events-none",
|
|
8048
|
+
"transition-opacity",
|
|
8049
|
+
"duration-200",
|
|
8050
|
+
"ease-in-out"
|
|
8051
|
+
];
|
|
8197
8052
|
switch (position) {
|
|
8198
8053
|
case "top-right":
|
|
8199
|
-
return
|
|
8200
|
-
...baseStyles,
|
|
8201
|
-
top: "100%",
|
|
8202
|
-
right: "0",
|
|
8203
|
-
marginTop: "8px"
|
|
8204
|
-
};
|
|
8054
|
+
return [...baseClasses, "top-full", "right-0", "mt-2"];
|
|
8205
8055
|
case "top-left":
|
|
8206
|
-
return
|
|
8207
|
-
...baseStyles,
|
|
8208
|
-
top: "100%",
|
|
8209
|
-
left: "0",
|
|
8210
|
-
marginTop: "8px"
|
|
8211
|
-
};
|
|
8056
|
+
return [...baseClasses, "top-full", "left-0", "mt-2"];
|
|
8212
8057
|
case "top-center":
|
|
8213
|
-
return
|
|
8214
|
-
...
|
|
8215
|
-
top
|
|
8216
|
-
left
|
|
8217
|
-
|
|
8218
|
-
|
|
8219
|
-
|
|
8058
|
+
return [
|
|
8059
|
+
...baseClasses,
|
|
8060
|
+
"top-full",
|
|
8061
|
+
"left-1/2",
|
|
8062
|
+
"-translate-x-1/2",
|
|
8063
|
+
"mt-2"
|
|
8064
|
+
];
|
|
8220
8065
|
case "bottom-right":
|
|
8221
|
-
return
|
|
8222
|
-
...baseStyles,
|
|
8223
|
-
bottom: "100%",
|
|
8224
|
-
right: "0",
|
|
8225
|
-
marginBottom: "8px"
|
|
8226
|
-
};
|
|
8066
|
+
return [...baseClasses, "bottom-full", "right-0", "mb-2"];
|
|
8227
8067
|
case "bottom-left":
|
|
8228
|
-
return
|
|
8229
|
-
...baseStyles,
|
|
8230
|
-
bottom: "100%",
|
|
8231
|
-
left: "0",
|
|
8232
|
-
marginBottom: "8px"
|
|
8233
|
-
};
|
|
8068
|
+
return [...baseClasses, "bottom-full", "left-0", "mb-2"];
|
|
8234
8069
|
case "bottom-center":
|
|
8235
|
-
return
|
|
8236
|
-
...
|
|
8237
|
-
bottom
|
|
8238
|
-
left
|
|
8239
|
-
|
|
8240
|
-
|
|
8241
|
-
|
|
8070
|
+
return [
|
|
8071
|
+
...baseClasses,
|
|
8072
|
+
"bottom-full",
|
|
8073
|
+
"left-1/2",
|
|
8074
|
+
"-translate-x-1/2",
|
|
8075
|
+
"mb-2"
|
|
8076
|
+
];
|
|
8242
8077
|
case "center-left":
|
|
8243
|
-
return
|
|
8244
|
-
...
|
|
8245
|
-
left
|
|
8246
|
-
top
|
|
8247
|
-
|
|
8248
|
-
|
|
8249
|
-
|
|
8078
|
+
return [
|
|
8079
|
+
...baseClasses,
|
|
8080
|
+
"left-full",
|
|
8081
|
+
"top-1/2",
|
|
8082
|
+
"-translate-y-1/2",
|
|
8083
|
+
"ml-2"
|
|
8084
|
+
];
|
|
8250
8085
|
case "center-right":
|
|
8251
|
-
return
|
|
8252
|
-
...
|
|
8253
|
-
right
|
|
8254
|
-
top
|
|
8255
|
-
|
|
8256
|
-
|
|
8257
|
-
|
|
8086
|
+
return [
|
|
8087
|
+
...baseClasses,
|
|
8088
|
+
"right-full",
|
|
8089
|
+
"top-1/2",
|
|
8090
|
+
"-translate-y-1/2",
|
|
8091
|
+
"mr-2"
|
|
8092
|
+
];
|
|
8258
8093
|
default:
|
|
8259
|
-
return
|
|
8260
|
-
...baseStyles,
|
|
8261
|
-
top: "100%",
|
|
8262
|
-
right: "0",
|
|
8263
|
-
marginTop: "8px"
|
|
8264
|
-
};
|
|
8094
|
+
return [...baseClasses, "top-full", "right-0", "mt-2"];
|
|
8265
8095
|
}
|
|
8266
|
-
}, "
|
|
8096
|
+
}, "getTooltipClasses");
|
|
8267
8097
|
const IconButton = /* @__PURE__ */ __name(({
|
|
8268
8098
|
onClick,
|
|
8269
8099
|
label,
|
|
8270
8100
|
children: icon
|
|
8271
8101
|
}) => {
|
|
8272
|
-
const [isButtonHovered, setIsButtonHovered] = (0,
|
|
8273
|
-
const
|
|
8274
|
-
return /* @__PURE__ */
|
|
8102
|
+
const [isButtonHovered, setIsButtonHovered] = (0, import_react6.useState)(false);
|
|
8103
|
+
const tooltipClasses = getTooltipClasses();
|
|
8104
|
+
return /* @__PURE__ */ import_react6.default.createElement(
|
|
8275
8105
|
"button",
|
|
8276
8106
|
{
|
|
8277
|
-
|
|
8278
|
-
|
|
8279
|
-
|
|
8280
|
-
color: buttonColor,
|
|
8281
|
-
border: "none",
|
|
8282
|
-
borderRadius: "8px",
|
|
8283
|
-
cursor: "pointer",
|
|
8284
|
-
display: "flex",
|
|
8285
|
-
alignItems: "center",
|
|
8286
|
-
justifyContent: "center",
|
|
8287
|
-
width: "32px",
|
|
8288
|
-
height: "32px",
|
|
8289
|
-
transition: "background-color 0.2s",
|
|
8290
|
-
backdropFilter: "blur(8px)",
|
|
8291
|
-
WebkitBackdropFilter: "blur(8px)",
|
|
8292
|
-
boxShadow: isDark ? "0 2px 8px rgba(0, 0, 0, 0.3)" : "0 2px 8px rgba(0, 0, 0, 0.2)",
|
|
8293
|
-
position: "relative"
|
|
8294
|
-
},
|
|
8295
|
-
onMouseEnter: (e) => {
|
|
8296
|
-
e.currentTarget.style.backgroundColor = buttonBgHover;
|
|
8297
|
-
setIsButtonHovered(true);
|
|
8298
|
-
},
|
|
8299
|
-
onMouseLeave: (e) => {
|
|
8300
|
-
e.currentTarget.style.backgroundColor = buttonBg;
|
|
8301
|
-
setIsButtonHovered(false);
|
|
8302
|
-
},
|
|
8107
|
+
className: `p-2 ${isDark ? "bg-white/10 hover:bg-white/20" : "bg-black/70 hover:bg-black/90"} text-white border-none rounded-lg cursor-pointer flex items-center justify-center w-8 h-8 transition-colors duration-200 backdrop-blur-md ${isDark ? "shadow-[0_2px_8px_rgba(0,0,0,0.3)]" : "shadow-[0_2px_8px_rgba(0,0,0,0.2)]"} relative`,
|
|
8108
|
+
onMouseEnter: () => setIsButtonHovered(true),
|
|
8109
|
+
onMouseLeave: () => setIsButtonHovered(false),
|
|
8303
8110
|
onClick,
|
|
8304
8111
|
"aria-label": label
|
|
8305
8112
|
},
|
|
8306
|
-
/* @__PURE__ */
|
|
8113
|
+
/* @__PURE__ */ import_react6.default.createElement(
|
|
8307
8114
|
"svg",
|
|
8308
8115
|
{
|
|
8309
8116
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -8315,17 +8122,14 @@ function WidgetDebugger({
|
|
|
8315
8122
|
strokeWidth: "2",
|
|
8316
8123
|
strokeLinecap: "round",
|
|
8317
8124
|
strokeLinejoin: "round",
|
|
8318
|
-
|
|
8125
|
+
className: "block"
|
|
8319
8126
|
},
|
|
8320
8127
|
icon
|
|
8321
8128
|
),
|
|
8322
|
-
showLabels && /* @__PURE__ */
|
|
8129
|
+
showLabels && /* @__PURE__ */ import_react6.default.createElement(
|
|
8323
8130
|
"span",
|
|
8324
8131
|
{
|
|
8325
|
-
|
|
8326
|
-
...tooltipStyles,
|
|
8327
|
-
opacity: isButtonHovered ? 1 : 0
|
|
8328
|
-
}
|
|
8132
|
+
className: `${tooltipClasses.join(" ")} ${isButtonHovered ? "opacity-100" : "opacity-0"}`
|
|
8329
8133
|
},
|
|
8330
8134
|
label
|
|
8331
8135
|
)
|
|
@@ -8352,570 +8156,248 @@ function WidgetDebugger({
|
|
|
8352
8156
|
const { top, bottom, left, right } = sa.insets;
|
|
8353
8157
|
return `T:${top} B:${bottom} L:${left} R:${right}`;
|
|
8354
8158
|
}, "formatSafeArea");
|
|
8355
|
-
return /* @__PURE__ */
|
|
8159
|
+
return /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, /* @__PURE__ */ import_react6.default.createElement(
|
|
8356
8160
|
"div",
|
|
8357
8161
|
{
|
|
8358
8162
|
ref: containerRef,
|
|
8359
|
-
className
|
|
8360
|
-
style: {
|
|
8361
|
-
position: "relative",
|
|
8362
|
-
height: "fit-content"
|
|
8363
|
-
},
|
|
8163
|
+
className: `${className} relative h-fit`,
|
|
8364
8164
|
onMouseEnter: () => !attachTo && setIsHovered(true),
|
|
8365
8165
|
onMouseLeave: () => !attachTo && setIsHovered(false)
|
|
8366
8166
|
},
|
|
8367
|
-
/* @__PURE__ */
|
|
8167
|
+
/* @__PURE__ */ import_react6.default.createElement(
|
|
8168
|
+
"div",
|
|
8169
|
+
{
|
|
8170
|
+
className: getPositionClasses().join(" "),
|
|
8171
|
+
style: getPositionOffsetStyles()
|
|
8172
|
+
},
|
|
8173
|
+
!isDevMode && /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, !isFullscreen && !isPip && /* @__PURE__ */ import_react6.default.createElement(import_react6.default.Fragment, null, (viewControls === true || viewControls === "fullscreen") && /* @__PURE__ */ import_react6.default.createElement(IconButton, { onClick: handleFullscreen, label: "Fullscreen" }, /* @__PURE__ */ import_react6.default.createElement("path", { d: "M15 3h6v6" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "m21 3-7 7" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "m3 21 7-7" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M9 21H3v-6" })), (viewControls === true || viewControls === "pip") && /* @__PURE__ */ import_react6.default.createElement(IconButton, { onClick: handlePip, label: "Picture in Picture" }, /* @__PURE__ */ import_react6.default.createElement("path", { d: "M21 9V6a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10c0 1.1.9 2 2 2h4" }), /* @__PURE__ */ import_react6.default.createElement("rect", { width: "10", height: "7", x: "12", y: "13", rx: "2" }))), enableDebugger && /* @__PURE__ */ import_react6.default.createElement(IconButton, { onClick: handleToggleOverlay, label: "Debug Info" }, /* @__PURE__ */ import_react6.default.createElement("path", { d: "M12 20v-9" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M14 7a4 4 0 0 1 4 4v3a6 6 0 0 1-12 0v-3a4 4 0 0 1 4-4z" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M14.12 3.88 16 2" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M21 21a4 4 0 0 0-3.81-4" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M21 5a4 4 0 0 1-3.55 3.97" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M22 13h-4" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M3 21a4 4 0 0 1 3.81-4" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M3 5a4 4 0 0 0 3.55 3.97" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M6 13H2" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "m8 2 1.88 1.88" }), /* @__PURE__ */ import_react6.default.createElement("path", { d: "M9 7.13V6a3 3 0 1 1 6 0v1.13" })))
|
|
8174
|
+
),
|
|
8368
8175
|
children
|
|
8369
|
-
), isOverlayOpen && /* @__PURE__ */
|
|
8176
|
+
), isOverlayOpen && enableDebugger && /* @__PURE__ */ import_react6.default.createElement(
|
|
8370
8177
|
"div",
|
|
8371
8178
|
{
|
|
8372
8179
|
ref: overlayRef,
|
|
8373
|
-
|
|
8374
|
-
position: "fixed",
|
|
8375
|
-
top: 0,
|
|
8376
|
-
left: 0,
|
|
8377
|
-
right: 0,
|
|
8378
|
-
bottom: 0,
|
|
8379
|
-
backgroundColor: "#000000",
|
|
8380
|
-
color: "#ffffff",
|
|
8381
|
-
fontFamily: "monospace",
|
|
8382
|
-
fontSize: "12px",
|
|
8383
|
-
zIndex: 1e4,
|
|
8384
|
-
overflow: "auto",
|
|
8385
|
-
padding: "16px"
|
|
8386
|
-
},
|
|
8180
|
+
className: "fixed inset-0 bg-black text-white font-mono text-xs z-[10000] overflow-auto p-4",
|
|
8387
8181
|
onClick: (e) => {
|
|
8388
8182
|
if (e.target === overlayRef.current) {
|
|
8389
8183
|
setIsOverlayOpen(false);
|
|
8390
8184
|
}
|
|
8391
8185
|
}
|
|
8392
8186
|
},
|
|
8393
|
-
/* @__PURE__ */
|
|
8187
|
+
/* @__PURE__ */ import_react6.default.createElement(
|
|
8394
8188
|
"button",
|
|
8395
8189
|
{
|
|
8396
8190
|
onClick: () => setIsOverlayOpen(false),
|
|
8397
|
-
|
|
8398
|
-
position: "absolute",
|
|
8399
|
-
top: "16px",
|
|
8400
|
-
right: "16px",
|
|
8401
|
-
backgroundColor: "rgba(255, 255, 255, 0.1)",
|
|
8402
|
-
color: "#ffffff",
|
|
8403
|
-
border: "none",
|
|
8404
|
-
borderRadius: "4px",
|
|
8405
|
-
width: "32px",
|
|
8406
|
-
height: "32px",
|
|
8407
|
-
cursor: "pointer",
|
|
8408
|
-
display: "flex",
|
|
8409
|
-
alignItems: "center",
|
|
8410
|
-
justifyContent: "center",
|
|
8411
|
-
fontSize: "18px",
|
|
8412
|
-
lineHeight: 1
|
|
8413
|
-
},
|
|
8191
|
+
className: "absolute top-4 right-4 bg-white/10 text-white border-none rounded w-8 h-8 cursor-pointer flex items-center justify-center text-lg leading-none",
|
|
8414
8192
|
"aria-label": "Close"
|
|
8415
8193
|
},
|
|
8416
8194
|
"\xD7"
|
|
8417
8195
|
),
|
|
8418
|
-
/* @__PURE__ */
|
|
8419
|
-
"
|
|
8196
|
+
/* @__PURE__ */ import_react6.default.createElement("div", { className: "max-w-[1200px] mx-auto pt-10" }, /* @__PURE__ */ import_react6.default.createElement("h1", { className: "text-lg font-bold mb-4 border-b border-gray-700 pb-2" }, "Debug Info"), /* @__PURE__ */ import_react6.default.createElement("table", { className: "w-full border-collapse border-spacing-0" }, /* @__PURE__ */ import_react6.default.createElement("tbody", null, /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Props"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 whitespace-pre-wrap break-all" }, formatValue(props))), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Output"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 whitespace-pre-wrap break-all" }, formatValue(output))), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Metadata"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 whitespace-pre-wrap break-all" }, formatValue(metadata))), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "State"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 whitespace-pre-wrap break-all" }, formatValue(state))), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Theme"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, theme)), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Display Mode"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, displayMode)), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Locale"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, locale)), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Max Height"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, maxHeight, "px")), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "User Agent"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, formatUserAgent(userAgent))), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "Safe Area"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, formatSafeArea(safeArea))), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "API Available"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, isAvailable ? "Yes" : "No")), /* @__PURE__ */ import_react6.default.createElement("tr", { className: "border-b border-gray-700" }, /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2 font-bold w-[200px] align-top" }, "window.openai Keys"), /* @__PURE__ */ import_react6.default.createElement("td", { className: "p-2" }, windowOpenAiKeys.length > 0 ? windowOpenAiKeys.join(", ") : "N/A")))), /* @__PURE__ */ import_react6.default.createElement("h2", { className: "text-base font-bold mt-8 mb-4 border-b border-gray-700 pb-2" }, "Actions"), /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex flex-col gap-3" }, /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ import_react6.default.createElement(
|
|
8197
|
+
"input",
|
|
8420
8198
|
{
|
|
8421
|
-
|
|
8199
|
+
type: "text",
|
|
8200
|
+
value: toolName,
|
|
8201
|
+
onChange: (e) => setToolName(e.target.value),
|
|
8202
|
+
placeholder: "Tool name",
|
|
8203
|
+
className: "py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs w-[150px]"
|
|
8204
|
+
}
|
|
8205
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
8206
|
+
"input",
|
|
8207
|
+
{
|
|
8208
|
+
type: "text",
|
|
8209
|
+
value: toolArgs,
|
|
8210
|
+
onChange: (e) => setToolArgs(e.target.value),
|
|
8211
|
+
placeholder: '{"key": "value"}',
|
|
8212
|
+
className: "py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"
|
|
8213
|
+
}
|
|
8214
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
8215
|
+
"button",
|
|
8216
|
+
{
|
|
8217
|
+
onClick: handleCallTool,
|
|
8218
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"
|
|
8422
8219
|
},
|
|
8423
|
-
|
|
8424
|
-
|
|
8425
|
-
|
|
8426
|
-
|
|
8427
|
-
|
|
8428
|
-
|
|
8429
|
-
|
|
8430
|
-
|
|
8431
|
-
|
|
8432
|
-
|
|
8433
|
-
|
|
8434
|
-
|
|
8435
|
-
|
|
8436
|
-
|
|
8437
|
-
"
|
|
8438
|
-
|
|
8439
|
-
|
|
8440
|
-
|
|
8441
|
-
|
|
8442
|
-
|
|
8443
|
-
|
|
8444
|
-
|
|
8445
|
-
|
|
8446
|
-
|
|
8447
|
-
|
|
8448
|
-
|
|
8449
|
-
|
|
8450
|
-
|
|
8451
|
-
|
|
8452
|
-
|
|
8453
|
-
|
|
8454
|
-
|
|
8455
|
-
|
|
8456
|
-
|
|
8457
|
-
|
|
8458
|
-
|
|
8459
|
-
|
|
8460
|
-
|
|
8461
|
-
|
|
8462
|
-
|
|
8463
|
-
|
|
8464
|
-
|
|
8465
|
-
|
|
8466
|
-
)
|
|
8467
|
-
|
|
8468
|
-
|
|
8469
|
-
|
|
8470
|
-
|
|
8471
|
-
|
|
8472
|
-
|
|
8473
|
-
|
|
8474
|
-
|
|
8475
|
-
|
|
8476
|
-
|
|
8477
|
-
|
|
8478
|
-
|
|
8479
|
-
|
|
8480
|
-
|
|
8481
|
-
|
|
8482
|
-
|
|
8483
|
-
|
|
8484
|
-
|
|
8485
|
-
|
|
8486
|
-
|
|
8487
|
-
)
|
|
8488
|
-
|
|
8489
|
-
|
|
8490
|
-
|
|
8491
|
-
|
|
8492
|
-
fontWeight: "bold",
|
|
8493
|
-
width: "200px",
|
|
8494
|
-
verticalAlign: "top"
|
|
8495
|
-
}
|
|
8496
|
-
},
|
|
8497
|
-
"Metadata"
|
|
8498
|
-
), /* @__PURE__ */ import_react4.default.createElement(
|
|
8499
|
-
"td",
|
|
8500
|
-
{
|
|
8501
|
-
style: {
|
|
8502
|
-
padding: "8px",
|
|
8503
|
-
whiteSpace: "pre-wrap",
|
|
8504
|
-
wordBreak: "break-all"
|
|
8505
|
-
}
|
|
8506
|
-
},
|
|
8507
|
-
formatValue(metadata)
|
|
8508
|
-
)), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
8509
|
-
"td",
|
|
8510
|
-
{
|
|
8511
|
-
style: {
|
|
8512
|
-
padding: "8px",
|
|
8513
|
-
fontWeight: "bold",
|
|
8514
|
-
width: "200px",
|
|
8515
|
-
verticalAlign: "top"
|
|
8516
|
-
}
|
|
8517
|
-
},
|
|
8518
|
-
"State"
|
|
8519
|
-
), /* @__PURE__ */ import_react4.default.createElement(
|
|
8520
|
-
"td",
|
|
8521
|
-
{
|
|
8522
|
-
style: {
|
|
8523
|
-
padding: "8px",
|
|
8524
|
-
whiteSpace: "pre-wrap",
|
|
8525
|
-
wordBreak: "break-all"
|
|
8526
|
-
}
|
|
8527
|
-
},
|
|
8528
|
-
formatValue(state)
|
|
8529
|
-
)), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
8530
|
-
"td",
|
|
8531
|
-
{
|
|
8532
|
-
style: {
|
|
8533
|
-
padding: "8px",
|
|
8534
|
-
fontWeight: "bold",
|
|
8535
|
-
width: "200px",
|
|
8536
|
-
verticalAlign: "top"
|
|
8537
|
-
}
|
|
8538
|
-
},
|
|
8539
|
-
"Theme"
|
|
8540
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, theme)), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
8541
|
-
"td",
|
|
8542
|
-
{
|
|
8543
|
-
style: {
|
|
8544
|
-
padding: "8px",
|
|
8545
|
-
fontWeight: "bold",
|
|
8546
|
-
width: "200px",
|
|
8547
|
-
verticalAlign: "top"
|
|
8548
|
-
}
|
|
8549
|
-
},
|
|
8550
|
-
"Display Mode"
|
|
8551
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, displayMode)), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
8552
|
-
"td",
|
|
8553
|
-
{
|
|
8554
|
-
style: {
|
|
8555
|
-
padding: "8px",
|
|
8556
|
-
fontWeight: "bold",
|
|
8557
|
-
width: "200px",
|
|
8558
|
-
verticalAlign: "top"
|
|
8559
|
-
}
|
|
8560
|
-
},
|
|
8561
|
-
"Locale"
|
|
8562
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, locale)), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
8563
|
-
"td",
|
|
8564
|
-
{
|
|
8565
|
-
style: {
|
|
8566
|
-
padding: "8px",
|
|
8567
|
-
fontWeight: "bold",
|
|
8568
|
-
width: "200px",
|
|
8569
|
-
verticalAlign: "top"
|
|
8570
|
-
}
|
|
8571
|
-
},
|
|
8572
|
-
"Max Height"
|
|
8573
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, maxHeight, "px")), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
8574
|
-
"td",
|
|
8575
|
-
{
|
|
8576
|
-
style: {
|
|
8577
|
-
padding: "8px",
|
|
8578
|
-
fontWeight: "bold",
|
|
8579
|
-
width: "200px",
|
|
8580
|
-
verticalAlign: "top"
|
|
8581
|
-
}
|
|
8582
|
-
},
|
|
8583
|
-
"User Agent"
|
|
8584
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, formatUserAgent(userAgent))), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
8585
|
-
"td",
|
|
8586
|
-
{
|
|
8587
|
-
style: {
|
|
8588
|
-
padding: "8px",
|
|
8589
|
-
fontWeight: "bold",
|
|
8590
|
-
width: "200px",
|
|
8591
|
-
verticalAlign: "top"
|
|
8592
|
-
}
|
|
8593
|
-
},
|
|
8594
|
-
"Safe Area"
|
|
8595
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, formatSafeArea(safeArea))), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
8596
|
-
"td",
|
|
8597
|
-
{
|
|
8598
|
-
style: {
|
|
8599
|
-
padding: "8px",
|
|
8600
|
-
fontWeight: "bold",
|
|
8601
|
-
width: "200px",
|
|
8602
|
-
verticalAlign: "top"
|
|
8603
|
-
}
|
|
8604
|
-
},
|
|
8605
|
-
"API Available"
|
|
8606
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, isAvailable ? "Yes" : "No")), /* @__PURE__ */ import_react4.default.createElement("tr", { style: { borderBottom: "1px solid #333" } }, /* @__PURE__ */ import_react4.default.createElement(
|
|
8607
|
-
"td",
|
|
8608
|
-
{
|
|
8609
|
-
style: {
|
|
8610
|
-
padding: "8px",
|
|
8611
|
-
fontWeight: "bold",
|
|
8612
|
-
width: "200px",
|
|
8613
|
-
verticalAlign: "top"
|
|
8614
|
-
}
|
|
8615
|
-
},
|
|
8616
|
-
"window.openai Keys"
|
|
8617
|
-
), /* @__PURE__ */ import_react4.default.createElement("td", { style: { padding: "8px" } }, windowOpenAiKeys.length > 0 ? windowOpenAiKeys.join(", ") : "N/A")))
|
|
8618
|
-
),
|
|
8619
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8620
|
-
"h2",
|
|
8621
|
-
{
|
|
8622
|
-
style: {
|
|
8623
|
-
fontSize: "16px",
|
|
8624
|
-
fontWeight: "bold",
|
|
8625
|
-
marginTop: "32px",
|
|
8626
|
-
marginBottom: "16px",
|
|
8627
|
-
borderBottom: "1px solid #333",
|
|
8628
|
-
paddingBottom: "8px"
|
|
8629
|
-
}
|
|
8630
|
-
},
|
|
8631
|
-
"Actions"
|
|
8632
|
-
),
|
|
8633
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8634
|
-
"div",
|
|
8635
|
-
{
|
|
8636
|
-
style: { display: "flex", flexDirection: "column", gap: "12px" }
|
|
8637
|
-
},
|
|
8638
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8639
|
-
"div",
|
|
8640
|
-
{
|
|
8641
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
8642
|
-
},
|
|
8643
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8644
|
-
"input",
|
|
8645
|
-
{
|
|
8646
|
-
type: "text",
|
|
8647
|
-
value: toolName,
|
|
8648
|
-
onChange: (e) => setToolName(e.target.value),
|
|
8649
|
-
placeholder: "Tool name",
|
|
8650
|
-
style: {
|
|
8651
|
-
padding: "6px 8px",
|
|
8652
|
-
backgroundColor: "#1a1a1a",
|
|
8653
|
-
color: "#ffffff",
|
|
8654
|
-
border: "1px solid #333",
|
|
8655
|
-
borderRadius: "4px",
|
|
8656
|
-
fontFamily: "monospace",
|
|
8657
|
-
fontSize: "12px",
|
|
8658
|
-
width: "150px"
|
|
8659
|
-
}
|
|
8660
|
-
}
|
|
8661
|
-
),
|
|
8662
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8663
|
-
"input",
|
|
8664
|
-
{
|
|
8665
|
-
type: "text",
|
|
8666
|
-
value: toolArgs,
|
|
8667
|
-
onChange: (e) => setToolArgs(e.target.value),
|
|
8668
|
-
placeholder: '{"key": "value"}',
|
|
8669
|
-
style: {
|
|
8670
|
-
padding: "6px 8px",
|
|
8671
|
-
backgroundColor: "#1a1a1a",
|
|
8672
|
-
color: "#ffffff",
|
|
8673
|
-
border: "1px solid #333",
|
|
8674
|
-
borderRadius: "4px",
|
|
8675
|
-
fontFamily: "monospace",
|
|
8676
|
-
fontSize: "12px",
|
|
8677
|
-
flex: 1
|
|
8678
|
-
}
|
|
8679
|
-
}
|
|
8680
|
-
),
|
|
8681
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8682
|
-
"button",
|
|
8683
|
-
{
|
|
8684
|
-
onClick: handleCallTool,
|
|
8685
|
-
style: {
|
|
8686
|
-
padding: "6px 12px",
|
|
8687
|
-
backgroundColor: "#333",
|
|
8688
|
-
color: "#ffffff",
|
|
8689
|
-
border: "1px solid #555",
|
|
8690
|
-
borderRadius: "4px",
|
|
8691
|
-
cursor: "pointer",
|
|
8692
|
-
fontFamily: "monospace",
|
|
8693
|
-
fontSize: "12px"
|
|
8694
|
-
}
|
|
8695
|
-
},
|
|
8696
|
-
"Call Tool"
|
|
8697
|
-
)
|
|
8698
|
-
),
|
|
8699
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8700
|
-
"div",
|
|
8701
|
-
{
|
|
8702
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
8703
|
-
},
|
|
8704
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8705
|
-
"input",
|
|
8706
|
-
{
|
|
8707
|
-
type: "text",
|
|
8708
|
-
value: followUpMessage,
|
|
8709
|
-
onChange: (e) => setFollowUpMessage(e.target.value),
|
|
8710
|
-
placeholder: "Follow-up message",
|
|
8711
|
-
style: {
|
|
8712
|
-
padding: "6px 8px",
|
|
8713
|
-
backgroundColor: "#1a1a1a",
|
|
8714
|
-
color: "#ffffff",
|
|
8715
|
-
border: "1px solid #333",
|
|
8716
|
-
borderRadius: "4px",
|
|
8717
|
-
fontFamily: "monospace",
|
|
8718
|
-
fontSize: "12px",
|
|
8719
|
-
flex: 1
|
|
8720
|
-
}
|
|
8721
|
-
}
|
|
8722
|
-
),
|
|
8723
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8724
|
-
"button",
|
|
8725
|
-
{
|
|
8726
|
-
onClick: handleSendFollowUpMessage,
|
|
8727
|
-
style: {
|
|
8728
|
-
padding: "6px 12px",
|
|
8729
|
-
backgroundColor: "#333",
|
|
8730
|
-
color: "#ffffff",
|
|
8731
|
-
border: "1px solid #555",
|
|
8732
|
-
borderRadius: "4px",
|
|
8733
|
-
cursor: "pointer",
|
|
8734
|
-
fontFamily: "monospace",
|
|
8735
|
-
fontSize: "12px"
|
|
8736
|
-
}
|
|
8737
|
-
},
|
|
8738
|
-
"Send Follow-Up"
|
|
8739
|
-
)
|
|
8740
|
-
),
|
|
8741
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8742
|
-
"div",
|
|
8743
|
-
{
|
|
8744
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
8745
|
-
},
|
|
8746
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8747
|
-
"input",
|
|
8748
|
-
{
|
|
8749
|
-
type: "text",
|
|
8750
|
-
value: externalUrl,
|
|
8751
|
-
onChange: (e) => setExternalUrl(e.target.value),
|
|
8752
|
-
placeholder: "External URL",
|
|
8753
|
-
style: {
|
|
8754
|
-
padding: "6px 8px",
|
|
8755
|
-
backgroundColor: "#1a1a1a",
|
|
8756
|
-
color: "#ffffff",
|
|
8757
|
-
border: "1px solid #333",
|
|
8758
|
-
borderRadius: "4px",
|
|
8759
|
-
fontFamily: "monospace",
|
|
8760
|
-
fontSize: "12px",
|
|
8761
|
-
flex: 1
|
|
8762
|
-
}
|
|
8763
|
-
}
|
|
8764
|
-
),
|
|
8765
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8766
|
-
"button",
|
|
8767
|
-
{
|
|
8768
|
-
onClick: handleOpenExternal,
|
|
8769
|
-
style: {
|
|
8770
|
-
padding: "6px 12px",
|
|
8771
|
-
backgroundColor: "#333",
|
|
8772
|
-
color: "#ffffff",
|
|
8773
|
-
border: "1px solid #555",
|
|
8774
|
-
borderRadius: "4px",
|
|
8775
|
-
cursor: "pointer",
|
|
8776
|
-
fontFamily: "monospace",
|
|
8777
|
-
fontSize: "12px"
|
|
8778
|
-
}
|
|
8779
|
-
},
|
|
8780
|
-
"Open Link"
|
|
8781
|
-
)
|
|
8782
|
-
),
|
|
8783
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8784
|
-
"div",
|
|
8785
|
-
{
|
|
8786
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
8787
|
-
},
|
|
8788
|
-
/* @__PURE__ */ import_react4.default.createElement("span", { style: { width: "150px", fontSize: "12px" } }, "Display Mode:"),
|
|
8789
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8790
|
-
"button",
|
|
8791
|
-
{
|
|
8792
|
-
onClick: () => handleRequestDisplayMode("inline"),
|
|
8793
|
-
style: {
|
|
8794
|
-
padding: "6px 12px",
|
|
8795
|
-
backgroundColor: "#333",
|
|
8796
|
-
color: "#ffffff",
|
|
8797
|
-
border: "1px solid #555",
|
|
8798
|
-
borderRadius: "4px",
|
|
8799
|
-
cursor: "pointer",
|
|
8800
|
-
fontFamily: "monospace",
|
|
8801
|
-
fontSize: "12px",
|
|
8802
|
-
flex: 1
|
|
8803
|
-
}
|
|
8804
|
-
},
|
|
8805
|
-
"Inline"
|
|
8806
|
-
),
|
|
8807
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8808
|
-
"button",
|
|
8809
|
-
{
|
|
8810
|
-
onClick: () => handleRequestDisplayMode("pip"),
|
|
8811
|
-
style: {
|
|
8812
|
-
padding: "6px 12px",
|
|
8813
|
-
backgroundColor: "#333",
|
|
8814
|
-
color: "#ffffff",
|
|
8815
|
-
border: "1px solid #555",
|
|
8816
|
-
borderRadius: "4px",
|
|
8817
|
-
cursor: "pointer",
|
|
8818
|
-
fontFamily: "monospace",
|
|
8819
|
-
fontSize: "12px",
|
|
8820
|
-
flex: 1
|
|
8821
|
-
}
|
|
8822
|
-
},
|
|
8823
|
-
"PiP"
|
|
8824
|
-
),
|
|
8825
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8826
|
-
"button",
|
|
8827
|
-
{
|
|
8828
|
-
onClick: () => handleRequestDisplayMode("fullscreen"),
|
|
8829
|
-
style: {
|
|
8830
|
-
padding: "6px 12px",
|
|
8831
|
-
backgroundColor: "#333",
|
|
8832
|
-
color: "#ffffff",
|
|
8833
|
-
border: "1px solid #555",
|
|
8834
|
-
borderRadius: "4px",
|
|
8835
|
-
cursor: "pointer",
|
|
8836
|
-
fontFamily: "monospace",
|
|
8837
|
-
fontSize: "12px",
|
|
8838
|
-
flex: 1
|
|
8839
|
-
}
|
|
8840
|
-
},
|
|
8841
|
-
"Fullscreen"
|
|
8842
|
-
)
|
|
8843
|
-
),
|
|
8844
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8845
|
-
"div",
|
|
8846
|
-
{
|
|
8847
|
-
style: { display: "flex", gap: "8px", alignItems: "center" }
|
|
8848
|
-
},
|
|
8849
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8850
|
-
"button",
|
|
8851
|
-
{
|
|
8852
|
-
onClick: handleSetState,
|
|
8853
|
-
style: {
|
|
8854
|
-
padding: "6px 12px",
|
|
8855
|
-
backgroundColor: "#333",
|
|
8856
|
-
color: "#ffffff",
|
|
8857
|
-
border: "1px solid #555",
|
|
8858
|
-
borderRadius: "4px",
|
|
8859
|
-
cursor: "pointer",
|
|
8860
|
-
fontFamily: "monospace",
|
|
8861
|
-
fontSize: "12px"
|
|
8862
|
-
}
|
|
8863
|
-
},
|
|
8864
|
-
"Set State (Add Timestamp)"
|
|
8865
|
-
)
|
|
8866
|
-
),
|
|
8867
|
-
actionResult && /* @__PURE__ */ import_react4.default.createElement(
|
|
8868
|
-
"div",
|
|
8869
|
-
{
|
|
8870
|
-
style: {
|
|
8871
|
-
marginTop: "8px",
|
|
8872
|
-
padding: "8px",
|
|
8873
|
-
backgroundColor: "#1a1a1a",
|
|
8874
|
-
border: "1px solid #333",
|
|
8875
|
-
borderRadius: "4px",
|
|
8876
|
-
whiteSpace: "pre-wrap",
|
|
8877
|
-
wordBreak: "break-all",
|
|
8878
|
-
fontSize: "11px",
|
|
8879
|
-
maxHeight: "200px",
|
|
8880
|
-
overflow: "auto"
|
|
8881
|
-
}
|
|
8882
|
-
},
|
|
8883
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8884
|
-
"div",
|
|
8885
|
-
{
|
|
8886
|
-
style: {
|
|
8887
|
-
fontWeight: "bold",
|
|
8888
|
-
marginBottom: "4px",
|
|
8889
|
-
color: "#aaa"
|
|
8890
|
-
}
|
|
8891
|
-
},
|
|
8892
|
-
"Result:"
|
|
8893
|
-
),
|
|
8894
|
-
actionResult,
|
|
8895
|
-
/* @__PURE__ */ import_react4.default.createElement(
|
|
8896
|
-
"button",
|
|
8897
|
-
{
|
|
8898
|
-
onClick: () => setActionResult(""),
|
|
8899
|
-
style: {
|
|
8900
|
-
marginTop: "8px",
|
|
8901
|
-
padding: "4px 8px",
|
|
8902
|
-
backgroundColor: "#333",
|
|
8903
|
-
color: "#ffffff",
|
|
8904
|
-
border: "1px solid #555",
|
|
8905
|
-
borderRadius: "4px",
|
|
8906
|
-
cursor: "pointer",
|
|
8907
|
-
fontFamily: "monospace",
|
|
8908
|
-
fontSize: "11px"
|
|
8909
|
-
}
|
|
8910
|
-
},
|
|
8911
|
-
"Clear"
|
|
8912
|
-
)
|
|
8913
|
-
)
|
|
8914
|
-
)
|
|
8915
|
-
)
|
|
8220
|
+
"Call Tool"
|
|
8221
|
+
)), /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ import_react6.default.createElement(
|
|
8222
|
+
"input",
|
|
8223
|
+
{
|
|
8224
|
+
type: "text",
|
|
8225
|
+
value: followUpMessage,
|
|
8226
|
+
onChange: (e) => setFollowUpMessage(e.target.value),
|
|
8227
|
+
placeholder: "Follow-up message",
|
|
8228
|
+
className: "py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"
|
|
8229
|
+
}
|
|
8230
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
8231
|
+
"button",
|
|
8232
|
+
{
|
|
8233
|
+
onClick: handleSendFollowUpMessage,
|
|
8234
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"
|
|
8235
|
+
},
|
|
8236
|
+
"Send Follow-Up"
|
|
8237
|
+
)), /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ import_react6.default.createElement(
|
|
8238
|
+
"input",
|
|
8239
|
+
{
|
|
8240
|
+
type: "text",
|
|
8241
|
+
value: externalUrl,
|
|
8242
|
+
onChange: (e) => setExternalUrl(e.target.value),
|
|
8243
|
+
placeholder: "External URL",
|
|
8244
|
+
className: "py-1.5 px-2 bg-[#1a1a1a] text-white border border-gray-700 rounded font-mono text-xs flex-1"
|
|
8245
|
+
}
|
|
8246
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
8247
|
+
"button",
|
|
8248
|
+
{
|
|
8249
|
+
onClick: handleOpenExternal,
|
|
8250
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"
|
|
8251
|
+
},
|
|
8252
|
+
"Open Link"
|
|
8253
|
+
)), /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ import_react6.default.createElement("span", { className: "w-[150px] text-xs" }, "Display Mode:"), /* @__PURE__ */ import_react6.default.createElement(
|
|
8254
|
+
"button",
|
|
8255
|
+
{
|
|
8256
|
+
onClick: () => handleRequestDisplayMode("inline"),
|
|
8257
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"
|
|
8258
|
+
},
|
|
8259
|
+
"Inline"
|
|
8260
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
8261
|
+
"button",
|
|
8262
|
+
{
|
|
8263
|
+
onClick: () => handleRequestDisplayMode("pip"),
|
|
8264
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"
|
|
8265
|
+
},
|
|
8266
|
+
"PiP"
|
|
8267
|
+
), /* @__PURE__ */ import_react6.default.createElement(
|
|
8268
|
+
"button",
|
|
8269
|
+
{
|
|
8270
|
+
onClick: () => handleRequestDisplayMode("fullscreen"),
|
|
8271
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs flex-1"
|
|
8272
|
+
},
|
|
8273
|
+
"Fullscreen"
|
|
8274
|
+
)), /* @__PURE__ */ import_react6.default.createElement("div", { className: "flex gap-2 items-center" }, /* @__PURE__ */ import_react6.default.createElement(
|
|
8275
|
+
"button",
|
|
8276
|
+
{
|
|
8277
|
+
onClick: handleSetState,
|
|
8278
|
+
className: "py-1.5 px-3 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-xs"
|
|
8279
|
+
},
|
|
8280
|
+
"Set State (Add Timestamp)"
|
|
8281
|
+
)), actionResult && /* @__PURE__ */ import_react6.default.createElement("div", { className: "mt-2 p-2 bg-[#1a1a1a] border border-gray-700 rounded whitespace-pre-wrap break-all text-[11px] max-h-[200px] overflow-auto" }, /* @__PURE__ */ import_react6.default.createElement("div", { className: "font-bold mb-1 text-gray-400" }, "Result:"), actionResult, /* @__PURE__ */ import_react6.default.createElement(
|
|
8282
|
+
"button",
|
|
8283
|
+
{
|
|
8284
|
+
onClick: () => setActionResult(""),
|
|
8285
|
+
className: "mt-2 py-1 px-2 bg-gray-800 text-white border border-gray-600 rounded cursor-pointer font-mono text-[11px]"
|
|
8286
|
+
},
|
|
8287
|
+
"Clear"
|
|
8288
|
+
))))
|
|
8916
8289
|
));
|
|
8917
8290
|
}
|
|
8918
|
-
__name(
|
|
8291
|
+
__name(WidgetControls, "WidgetControls");
|
|
8292
|
+
|
|
8293
|
+
// src/react/McpUseProvider.tsx
|
|
8294
|
+
var import_react7 = __toESM(require("react"), 1);
|
|
8295
|
+
var import_react_router_dom = require("react-router-dom");
|
|
8296
|
+
function getBasename() {
|
|
8297
|
+
if (typeof window === "undefined") return "/";
|
|
8298
|
+
const path4 = window.location.pathname;
|
|
8299
|
+
const match = path4.match(/^(\/inspector\/api\/dev-widget\/[^/]+)/);
|
|
8300
|
+
if (match) {
|
|
8301
|
+
return match[1];
|
|
8302
|
+
}
|
|
8303
|
+
return "/";
|
|
8304
|
+
}
|
|
8305
|
+
__name(getBasename, "getBasename");
|
|
8306
|
+
var HEIGHT_DEBOUNCE_MS = 150;
|
|
8307
|
+
var MIN_HEIGHT_CHANGE_PX = 5;
|
|
8308
|
+
function McpUseProvider({
|
|
8309
|
+
children,
|
|
8310
|
+
debugger: enableDebugger = false,
|
|
8311
|
+
viewControls = false,
|
|
8312
|
+
autoSize = false
|
|
8313
|
+
}) {
|
|
8314
|
+
const basename = getBasename();
|
|
8315
|
+
const containerRef = (0, import_react7.useRef)(null);
|
|
8316
|
+
const lastHeightRef = (0, import_react7.useRef)(0);
|
|
8317
|
+
const debounceTimeoutRef = (0, import_react7.useRef)(null);
|
|
8318
|
+
const notificationInProgressRef = (0, import_react7.useRef)(false);
|
|
8319
|
+
const notifyHeight = (0, import_react7.useCallback)((height) => {
|
|
8320
|
+
if (typeof window !== "undefined" && window.openai?.notifyIntrinsicHeight) {
|
|
8321
|
+
notificationInProgressRef.current = true;
|
|
8322
|
+
window.openai.notifyIntrinsicHeight(height).then(() => {
|
|
8323
|
+
notificationInProgressRef.current = false;
|
|
8324
|
+
}).catch((error) => {
|
|
8325
|
+
notificationInProgressRef.current = false;
|
|
8326
|
+
console.error(
|
|
8327
|
+
"[McpUseProvider] Failed to notify intrinsic height:",
|
|
8328
|
+
error
|
|
8329
|
+
);
|
|
8330
|
+
});
|
|
8331
|
+
}
|
|
8332
|
+
}, []);
|
|
8333
|
+
const debouncedNotifyHeight = (0, import_react7.useCallback)(
|
|
8334
|
+
(height) => {
|
|
8335
|
+
if (debounceTimeoutRef.current) {
|
|
8336
|
+
clearTimeout(debounceTimeoutRef.current);
|
|
8337
|
+
}
|
|
8338
|
+
debounceTimeoutRef.current = setTimeout(() => {
|
|
8339
|
+
const heightDiff = Math.abs(height - lastHeightRef.current);
|
|
8340
|
+
if (heightDiff >= MIN_HEIGHT_CHANGE_PX && height > 0) {
|
|
8341
|
+
lastHeightRef.current = height;
|
|
8342
|
+
notifyHeight(height);
|
|
8343
|
+
}
|
|
8344
|
+
}, HEIGHT_DEBOUNCE_MS);
|
|
8345
|
+
},
|
|
8346
|
+
[notifyHeight]
|
|
8347
|
+
);
|
|
8348
|
+
(0, import_react7.useEffect)(() => {
|
|
8349
|
+
if (!autoSize) {
|
|
8350
|
+
return;
|
|
8351
|
+
}
|
|
8352
|
+
const container = containerRef.current;
|
|
8353
|
+
if (!container || typeof ResizeObserver === "undefined") {
|
|
8354
|
+
return;
|
|
8355
|
+
}
|
|
8356
|
+
const observer = new ResizeObserver((entries) => {
|
|
8357
|
+
if (notificationInProgressRef.current) {
|
|
8358
|
+
return;
|
|
8359
|
+
}
|
|
8360
|
+
for (const entry of entries) {
|
|
8361
|
+
const height = entry.contentRect.height;
|
|
8362
|
+
const scrollHeight = entry.target.scrollHeight;
|
|
8363
|
+
const intrinsicHeight = Math.max(height, scrollHeight);
|
|
8364
|
+
debouncedNotifyHeight(intrinsicHeight);
|
|
8365
|
+
}
|
|
8366
|
+
});
|
|
8367
|
+
observer.observe(container);
|
|
8368
|
+
const initialHeight = Math.max(
|
|
8369
|
+
container.offsetHeight,
|
|
8370
|
+
container.scrollHeight
|
|
8371
|
+
);
|
|
8372
|
+
if (initialHeight > 0) {
|
|
8373
|
+
debouncedNotifyHeight(initialHeight);
|
|
8374
|
+
}
|
|
8375
|
+
return () => {
|
|
8376
|
+
observer.disconnect();
|
|
8377
|
+
if (debounceTimeoutRef.current) {
|
|
8378
|
+
clearTimeout(debounceTimeoutRef.current);
|
|
8379
|
+
debounceTimeoutRef.current = null;
|
|
8380
|
+
}
|
|
8381
|
+
notificationInProgressRef.current = false;
|
|
8382
|
+
};
|
|
8383
|
+
}, [autoSize, debouncedNotifyHeight]);
|
|
8384
|
+
let content = children;
|
|
8385
|
+
content = /* @__PURE__ */ import_react7.default.createElement(ErrorBoundary, null, content);
|
|
8386
|
+
if (enableDebugger || viewControls) {
|
|
8387
|
+
content = /* @__PURE__ */ import_react7.default.createElement(WidgetControls, { debugger: enableDebugger, viewControls }, content);
|
|
8388
|
+
}
|
|
8389
|
+
content = /* @__PURE__ */ import_react7.default.createElement(import_react_router_dom.BrowserRouter, { basename }, content);
|
|
8390
|
+
content = /* @__PURE__ */ import_react7.default.createElement(ThemeProvider, null, content);
|
|
8391
|
+
if (autoSize) {
|
|
8392
|
+
const containerStyle = {
|
|
8393
|
+
width: "100%",
|
|
8394
|
+
minHeight: 0
|
|
8395
|
+
};
|
|
8396
|
+
content = /* @__PURE__ */ import_react7.default.createElement("div", { ref: containerRef, style: containerStyle }, content);
|
|
8397
|
+
}
|
|
8398
|
+
return /* @__PURE__ */ import_react7.default.createElement(import_react7.StrictMode, null, content);
|
|
8399
|
+
}
|
|
8400
|
+
__name(McpUseProvider, "McpUseProvider");
|
|
8919
8401
|
|
|
8920
8402
|
// src/client/prompts.ts
|
|
8921
8403
|
var PROMPTS = {
|