@productmaker/mcp 12.36.1 → 12.44.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -5
- package/dist/http.js +12470 -10170
- package/dist/stdio.js +11559 -9606
- package/dist/ui/guided-step-app.html +952 -0
- package/dist/ui/meta-upload-app.html +98 -26
- package/dist/ui/task-results-app.html +620 -93
- package/package.json +2 -1
|
@@ -527,6 +527,8 @@
|
|
|
527
527
|
const RPC_TIMEOUT_MS = 15000;
|
|
528
528
|
const APP_PROTOCOL_VERSION = "2026-01-26";
|
|
529
529
|
const CONFIGURED_RESOLVE_ENDPOINT = "__PRODUCTMAKER_RESOLVE_ENDPOINT__";
|
|
530
|
+
const CHATGPT_ATTACHMENT_STORAGE_ORIGIN =
|
|
531
|
+
"__PRODUCTMAKER_CHATGPT_ATTACHMENT_ORIGIN__";
|
|
530
532
|
|
|
531
533
|
const elements = {
|
|
532
534
|
root: document.querySelector('[data-testid="meta-upload-root"]'),
|
|
@@ -930,14 +932,45 @@
|
|
|
930
932
|
typeof bridge.selectFiles === "function" &&
|
|
931
933
|
typeof bridge.getFileDownloadUrl === "function"
|
|
932
934
|
);
|
|
933
|
-
if (bridge
|
|
935
|
+
if (!bridge) return;
|
|
936
|
+
const result = readOpenAiAttachmentResult(
|
|
937
|
+
bridge.toolResponseMetadata,
|
|
938
|
+
);
|
|
939
|
+
// ChatGPT can retain the previous input and output on a failed call.
|
|
940
|
+
if (result?.isError === true) return;
|
|
941
|
+
if (isRecord(bridge.toolInput)) {
|
|
934
942
|
mergeToolInput(bridge.toolInput);
|
|
935
943
|
}
|
|
936
|
-
if (
|
|
937
|
-
applyToolResult({
|
|
944
|
+
if (isRecord(bridge.toolOutput)) {
|
|
945
|
+
applyToolResult({
|
|
946
|
+
structuredContent: bridge.toolOutput,
|
|
947
|
+
_meta: result?._meta,
|
|
948
|
+
});
|
|
938
949
|
}
|
|
939
950
|
}
|
|
940
951
|
|
|
952
|
+
function readOpenAiAttachmentResult(metadata) {
|
|
953
|
+
if (!isRecord(metadata)) return;
|
|
954
|
+
// Match the known ChatGPT tool result envelopes used by the results viewer.
|
|
955
|
+
const callResult = isRecord(metadata.call_tool_result)
|
|
956
|
+
? metadata.call_tool_result
|
|
957
|
+
: null;
|
|
958
|
+
const candidates = [
|
|
959
|
+
metadata.mcp_tool_result,
|
|
960
|
+
callResult?.mcp_tool_result,
|
|
961
|
+
callResult,
|
|
962
|
+
metadata,
|
|
963
|
+
{ _meta: metadata },
|
|
964
|
+
];
|
|
965
|
+
return candidates.find(
|
|
966
|
+
(candidate) =>
|
|
967
|
+
isRecord(candidate) &&
|
|
968
|
+
(candidate.isError === true ||
|
|
969
|
+
(isRecord(candidate._meta) &&
|
|
970
|
+
Array.isArray(candidate._meta.attachedFiles))),
|
|
971
|
+
);
|
|
972
|
+
}
|
|
973
|
+
|
|
941
974
|
function bindUi() {
|
|
942
975
|
elements.pickerButton.addEventListener("click", () =>
|
|
943
976
|
elements.input.click(),
|
|
@@ -1161,6 +1194,12 @@
|
|
|
1161
1194
|
if (!candidate) return;
|
|
1162
1195
|
const session = parseSession(candidate);
|
|
1163
1196
|
if (!session) return;
|
|
1197
|
+
const attachedFiles = isRecord(result._meta)
|
|
1198
|
+
? result._meta.attachedFiles
|
|
1199
|
+
: undefined;
|
|
1200
|
+
if (Array.isArray(attachedFiles)) {
|
|
1201
|
+
state.toolInput = { ...state.toolInput, files: attachedFiles };
|
|
1202
|
+
}
|
|
1164
1203
|
const sessionChanged =
|
|
1165
1204
|
!state.session || state.session.sessionId !== session.sessionId;
|
|
1166
1205
|
if (sessionChanged) {
|
|
@@ -1303,7 +1342,11 @@
|
|
|
1303
1342
|
return id && !state.consumedBridgeIds.has(id);
|
|
1304
1343
|
});
|
|
1305
1344
|
if (!pending.length) return;
|
|
1306
|
-
|
|
1345
|
+
const canUseBridge = hasOpenAiFunction("getFileDownloadUrl");
|
|
1346
|
+
const downloadable = pending.filter(
|
|
1347
|
+
(reference) => canUseBridge || referenceDownloadUrl(reference),
|
|
1348
|
+
);
|
|
1349
|
+
if (!downloadable.length) {
|
|
1307
1350
|
requireFallback(
|
|
1308
1351
|
"Este host no expone el puente de archivos. Usa el selector o el enlace seguro.",
|
|
1309
1352
|
"warning",
|
|
@@ -1315,7 +1358,7 @@
|
|
|
1315
1358
|
safeSessionLimit() - state.items.length,
|
|
1316
1359
|
);
|
|
1317
1360
|
const files = [];
|
|
1318
|
-
for (const reference of
|
|
1361
|
+
for (const reference of downloadable.slice(0, availableSlots)) {
|
|
1319
1362
|
const id = normalizedBridgeReferenceId(reference);
|
|
1320
1363
|
try {
|
|
1321
1364
|
const file = await downloadBridgeReference(reference, work);
|
|
@@ -1336,13 +1379,14 @@
|
|
|
1336
1379
|
Array.isArray(state.toolInput.files) &&
|
|
1337
1380
|
state.toolInput.files.some((reference) => {
|
|
1338
1381
|
const id = normalizedBridgeReferenceId(reference);
|
|
1339
|
-
return
|
|
1382
|
+
return (
|
|
1383
|
+
id &&
|
|
1384
|
+
!state.consumedBridgeIds.has(id) &&
|
|
1385
|
+
(hasOpenAiFunction("getFileDownloadUrl") ||
|
|
1386
|
+
referenceDownloadUrl(reference))
|
|
1387
|
+
);
|
|
1340
1388
|
});
|
|
1341
|
-
if (
|
|
1342
|
-
hasUnconsumed &&
|
|
1343
|
-
hasOpenAiFunction("getFileDownloadUrl") &&
|
|
1344
|
-
state.items.length < safeSessionLimit()
|
|
1345
|
-
) {
|
|
1389
|
+
if (hasUnconsumed && state.items.length < safeSessionLimit()) {
|
|
1346
1390
|
queueMicrotask(() => void consumePendingBridgeFiles());
|
|
1347
1391
|
}
|
|
1348
1392
|
}
|
|
@@ -1440,27 +1484,43 @@
|
|
|
1440
1484
|
);
|
|
1441
1485
|
}
|
|
1442
1486
|
|
|
1487
|
+
function referenceDownloadUrl(reference) {
|
|
1488
|
+
try {
|
|
1489
|
+
const url = new URL(normalizedBridgeDownloadUrl(reference));
|
|
1490
|
+
return safeBridgeDownloadUrl(url) ? url.href : "";
|
|
1491
|
+
} catch {
|
|
1492
|
+
return "";
|
|
1493
|
+
}
|
|
1494
|
+
}
|
|
1495
|
+
|
|
1443
1496
|
async function downloadBridgeReference(reference, work) {
|
|
1444
1497
|
requireCurrentUploadWork(work);
|
|
1445
1498
|
const bridge = openAiBridge();
|
|
1446
|
-
if (!bridge || typeof bridge.getFileDownloadUrl !== "function") {
|
|
1447
|
-
throw new Error("bridge_download_unavailable");
|
|
1448
|
-
}
|
|
1449
1499
|
const fileId = normalizedBridgeReferenceId(reference);
|
|
1450
1500
|
if (!fileId) throw new Error("invalid_bridge_file");
|
|
1451
|
-
const
|
|
1501
|
+
const suppliedUrl = referenceDownloadUrl(reference);
|
|
1502
|
+
let freshUrl = "";
|
|
1503
|
+
if (typeof bridge?.getFileDownloadUrl === "function") {
|
|
1504
|
+
try {
|
|
1505
|
+
freshUrl = referenceDownloadUrl(
|
|
1506
|
+
await bridge.getFileDownloadUrl({ fileId }),
|
|
1507
|
+
);
|
|
1508
|
+
} catch (error) {
|
|
1509
|
+
if (!suppliedUrl) throw error;
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1512
|
+
requireCurrentUploadWork(work);
|
|
1513
|
+
const url = freshUrl || suppliedUrl;
|
|
1514
|
+
if (!url) throw new Error("unsafe_bridge_url");
|
|
1515
|
+
let response;
|
|
1516
|
+
try {
|
|
1517
|
+
response = await fetchBridgeDownload(url, work);
|
|
1518
|
+
} catch (error) {
|
|
1519
|
+
requireCurrentUploadWork(work);
|
|
1520
|
+
if (!suppliedUrl || url === suppliedUrl) throw error;
|
|
1521
|
+
response = await fetchBridgeDownload(suppliedUrl, work);
|
|
1522
|
+
}
|
|
1452
1523
|
requireCurrentUploadWork(work);
|
|
1453
|
-
const temporaryUrl = normalizedBridgeDownloadUrl(resolved);
|
|
1454
|
-
const parsedUrl = new URL(temporaryUrl);
|
|
1455
|
-
if (!safeBridgeDownloadUrl(parsedUrl))
|
|
1456
|
-
throw new Error("unsafe_bridge_url");
|
|
1457
|
-
const response = await fetch(parsedUrl.toString(), {
|
|
1458
|
-
method: "GET",
|
|
1459
|
-
credentials: "omit",
|
|
1460
|
-
redirect: "error",
|
|
1461
|
-
signal: work.signal,
|
|
1462
|
-
});
|
|
1463
|
-
if (!response.ok) throw new Error("bridge_download_failed");
|
|
1464
1524
|
const blob = await readBoundedBridgeBlob(response);
|
|
1465
1525
|
requireCurrentUploadWork(work);
|
|
1466
1526
|
const preferredType = boundedString(
|
|
@@ -1486,6 +1546,17 @@
|
|
|
1486
1546
|
});
|
|
1487
1547
|
}
|
|
1488
1548
|
|
|
1549
|
+
async function fetchBridgeDownload(url, work) {
|
|
1550
|
+
const response = await fetch(url, {
|
|
1551
|
+
method: "GET",
|
|
1552
|
+
credentials: "omit",
|
|
1553
|
+
redirect: "error",
|
|
1554
|
+
signal: work.signal,
|
|
1555
|
+
});
|
|
1556
|
+
if (!response.ok) throw new Error("bridge_download_failed");
|
|
1557
|
+
return response;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1489
1560
|
async function readBoundedBridgeBlob(response) {
|
|
1490
1561
|
const declaredLength = Number(
|
|
1491
1562
|
response.headers.get("content-length") || "",
|
|
@@ -2165,6 +2236,7 @@
|
|
|
2165
2236
|
return false;
|
|
2166
2237
|
const hostname = url.hostname.toLowerCase();
|
|
2167
2238
|
return (
|
|
2239
|
+
url.origin === CHATGPT_ATTACHMENT_STORAGE_ORIGIN ||
|
|
2168
2240
|
hostname === "files.oaiusercontent.com" ||
|
|
2169
2241
|
hostname.endsWith(".oaiusercontent.com")
|
|
2170
2242
|
);
|