@mcp-use/client 2.0.0-beta.2 → 2.0.0-beta.3
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/index-browser.js +1 -1
- package/dist/index.js +1 -1
- package/dist/react/index.js +58 -4
- package/dist/react/index.js.map +1 -1
- package/dist/react/view/ViewRenderer.d.ts +2 -1
- package/dist/react/view/ViewRenderer.d.ts.map +1 -1
- package/dist/react/view/inject-openai-file-apis.d.ts +6 -0
- package/dist/react/view/inject-openai-file-apis.d.ts.map +1 -0
- package/dist/react/view/types.d.ts +2 -0
- package/dist/react/view/types.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index-browser.js
CHANGED
package/dist/index.js
CHANGED
package/dist/react/index.js
CHANGED
|
@@ -1473,7 +1473,7 @@ var HttpConnector = class extends BaseConnector {
|
|
|
1473
1473
|
};
|
|
1474
1474
|
|
|
1475
1475
|
// src/utils/version.ts
|
|
1476
|
-
var VERSION = "2.0.0-beta.
|
|
1476
|
+
var VERSION = "2.0.0-beta.2";
|
|
1477
1477
|
function getPackageVersion() {
|
|
1478
1478
|
return VERSION;
|
|
1479
1479
|
}
|
|
@@ -6903,6 +6903,53 @@ function parseCustomProps(customProps) {
|
|
|
6903
6903
|
return parsed;
|
|
6904
6904
|
}
|
|
6905
6905
|
|
|
6906
|
+
// src/react/view/inject-openai-file-apis.ts
|
|
6907
|
+
var OPENAI_FILE_APIS_SCRIPT = `<script>
|
|
6908
|
+
(function () {
|
|
6909
|
+
var files = new Map();
|
|
6910
|
+
window.openai = window.openai || {};
|
|
6911
|
+
window.openai.uploadFile = async function (file) {
|
|
6912
|
+
var fileId = crypto.randomUUID();
|
|
6913
|
+
files.set(fileId, file);
|
|
6914
|
+
return { fileId: fileId };
|
|
6915
|
+
};
|
|
6916
|
+
window.openai.getFileDownloadUrl = async function (ref) {
|
|
6917
|
+
var file = files.get(ref.fileId);
|
|
6918
|
+
if (!file) {
|
|
6919
|
+
throw new Error("File not found: " + ref.fileId);
|
|
6920
|
+
}
|
|
6921
|
+
return { downloadUrl: URL.createObjectURL(file) };
|
|
6922
|
+
};
|
|
6923
|
+
})();
|
|
6924
|
+
</script>`;
|
|
6925
|
+
function injectOpenAiFileApis(html) {
|
|
6926
|
+
if (html.includes("<head>")) {
|
|
6927
|
+
return html.replace("<head>", "<head>" + OPENAI_FILE_APIS_SCRIPT);
|
|
6928
|
+
}
|
|
6929
|
+
if (html.includes("<HEAD>")) {
|
|
6930
|
+
return html.replace("<HEAD>", "<HEAD>" + OPENAI_FILE_APIS_SCRIPT);
|
|
6931
|
+
}
|
|
6932
|
+
if (html.includes("<html>")) {
|
|
6933
|
+
return html.replace(
|
|
6934
|
+
"<html>",
|
|
6935
|
+
"<html><head>" + OPENAI_FILE_APIS_SCRIPT + "</head>"
|
|
6936
|
+
);
|
|
6937
|
+
}
|
|
6938
|
+
if (html.includes("<HTML>")) {
|
|
6939
|
+
return html.replace(
|
|
6940
|
+
"<HTML>",
|
|
6941
|
+
"<HTML><head>" + OPENAI_FILE_APIS_SCRIPT + "</head>"
|
|
6942
|
+
);
|
|
6943
|
+
}
|
|
6944
|
+
if (html.includes("<!DOCTYPE") || html.includes("<!doctype")) {
|
|
6945
|
+
return html.replace(
|
|
6946
|
+
/(<!DOCTYPE[^>]*>|<!doctype[^>]*>)/i,
|
|
6947
|
+
"$1<head>" + OPENAI_FILE_APIS_SCRIPT + "</head>"
|
|
6948
|
+
);
|
|
6949
|
+
}
|
|
6950
|
+
return OPENAI_FILE_APIS_SCRIPT + html;
|
|
6951
|
+
}
|
|
6952
|
+
|
|
6906
6953
|
// src/react/view/resolve-view-resource.ts
|
|
6907
6954
|
function resolveViewResource(options) {
|
|
6908
6955
|
const { resourceResult, listingResource, cspMode, resourceUri } = options;
|
|
@@ -7339,7 +7386,9 @@ var DEFAULT_HOST_CAPABILITIES = {
|
|
|
7339
7386
|
serverTools: {},
|
|
7340
7387
|
serverResources: {},
|
|
7341
7388
|
logging: {},
|
|
7342
|
-
updateModelContext: { text: {} }
|
|
7389
|
+
updateModelContext: { text: {} },
|
|
7390
|
+
// ponytail: always advertised; bridge.onmessage no-ops when onMessage unset
|
|
7391
|
+
message: { text: {} }
|
|
7343
7392
|
};
|
|
7344
7393
|
function waitForSandboxProxyReady(iframe) {
|
|
7345
7394
|
return new Promise((resolve) => {
|
|
@@ -7401,6 +7450,7 @@ function ViewRendererBase({
|
|
|
7401
7450
|
onResourceResolved,
|
|
7402
7451
|
wrapTransport,
|
|
7403
7452
|
toolCallTimeout = DEFAULT_TOOL_CALL_TIMEOUT,
|
|
7453
|
+
mockOpenAiFileApis = false,
|
|
7404
7454
|
className,
|
|
7405
7455
|
testId = "mcp-app-frame",
|
|
7406
7456
|
invoking,
|
|
@@ -7450,6 +7500,8 @@ function ViewRendererBase({
|
|
|
7450
7500
|
sandboxUrlRef.current = sandboxUrl;
|
|
7451
7501
|
const cspModeRef = useRef4(cspMode);
|
|
7452
7502
|
cspModeRef.current = cspMode;
|
|
7503
|
+
const mockOpenAiFileApisRef = useRef4(mockOpenAiFileApis);
|
|
7504
|
+
mockOpenAiFileApisRef.current = mockOpenAiFileApis;
|
|
7453
7505
|
const resolveSandboxUrl = useCallback6((next) => {
|
|
7454
7506
|
const custom = sandboxUrlRef.current;
|
|
7455
7507
|
if (custom) {
|
|
@@ -7716,7 +7768,7 @@ function ViewRendererBase({
|
|
|
7716
7768
|
await bridge.connect(transport);
|
|
7717
7769
|
if (disposed) return;
|
|
7718
7770
|
await bridge.sendSandboxResourceReady({
|
|
7719
|
-
html: resolved.html,
|
|
7771
|
+
html: mockOpenAiFileApisRef.current ? injectOpenAiFileApis(resolved.html) : resolved.html,
|
|
7720
7772
|
csp: resolved.csp,
|
|
7721
7773
|
permissions: resolved.permissions
|
|
7722
7774
|
});
|
|
@@ -7778,7 +7830,8 @@ function ViewRendererBase({
|
|
|
7778
7830
|
cspMode,
|
|
7779
7831
|
viewId,
|
|
7780
7832
|
wrapTransport,
|
|
7781
|
-
toolCallTimeout
|
|
7833
|
+
toolCallTimeout,
|
|
7834
|
+
mockOpenAiFileApis
|
|
7782
7835
|
]);
|
|
7783
7836
|
useEffect5(() => {
|
|
7784
7837
|
const bridge = bridgeRef.current;
|
|
@@ -7902,6 +7955,7 @@ function viewRendererAreEqual(prev, next) {
|
|
|
7902
7955
|
if (prev.hostContext !== next.hostContext) return false;
|
|
7903
7956
|
if (prev.hostCapabilities !== next.hostCapabilities) return false;
|
|
7904
7957
|
if (prev.cspMode !== next.cspMode) return false;
|
|
7958
|
+
if (prev.mockOpenAiFileApis !== next.mockOpenAiFileApis) return false;
|
|
7905
7959
|
if (prev.className !== next.className) return false;
|
|
7906
7960
|
if (prev.onReady !== next.onReady) return false;
|
|
7907
7961
|
if (prev.onLifecycleChange !== next.onLifecycleChange) return false;
|