adp-openclaw 0.0.60 → 0.0.61
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/package.json +1 -1
- package/src/monitor.ts +34 -2
package/package.json
CHANGED
package/src/monitor.ts
CHANGED
|
@@ -431,9 +431,41 @@ async function connectAndHandle(params: ConnectParams): Promise<void> {
|
|
|
431
431
|
// 移除事件监听
|
|
432
432
|
uploadResultEmitter.off(UPLOAD_RESULT_EVENT, uploadResultHandler);
|
|
433
433
|
|
|
434
|
-
//
|
|
434
|
+
// 如果有上传结果,修正 LLM 可能篡改的签名 URL,并追加完整下载链接
|
|
435
435
|
let finalText = text;
|
|
436
436
|
if (pendingUploadResults.length > 0) {
|
|
437
|
+
// Build a map: COS path (without query params) -> correct full URL
|
|
438
|
+
// LLM may reproduce the URL with subtle character errors in the
|
|
439
|
+
// q-signature (hex hallucination). We fix this by matching on the
|
|
440
|
+
// base path and replacing the entire URL with the correct one.
|
|
441
|
+
const correctUrlMap = new Map<string, string>();
|
|
442
|
+
for (const result of pendingUploadResults) {
|
|
443
|
+
for (const file of (result.files || [])) {
|
|
444
|
+
if (file.downloadUrl) {
|
|
445
|
+
try {
|
|
446
|
+
const basePath = file.downloadUrl.split("?")[0];
|
|
447
|
+
correctUrlMap.set(basePath, file.downloadUrl);
|
|
448
|
+
} catch { /* ignore */ }
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
}
|
|
452
|
+
|
|
453
|
+
// Replace any LLM-generated URLs that share the same base path
|
|
454
|
+
// but may have corrupted query parameters (signature hallucination)
|
|
455
|
+
if (correctUrlMap.size > 0) {
|
|
456
|
+
for (const [basePath, correctUrl] of correctUrlMap) {
|
|
457
|
+
// Escape basePath for use in regex
|
|
458
|
+
const escaped = basePath.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
459
|
+
// Match the base path followed by any query string
|
|
460
|
+
const pattern = new RegExp(escaped + "\\?[^\\s)\\]]*", "g");
|
|
461
|
+
const before = finalText;
|
|
462
|
+
finalText = finalText.replace(pattern, correctUrl);
|
|
463
|
+
if (finalText !== before) {
|
|
464
|
+
log?.info(`[adp-openclaw] Fixed LLM-corrupted URL for: ${basePath.substring(basePath.lastIndexOf("/") + 1)}`);
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
}
|
|
468
|
+
|
|
437
469
|
const uploadLinks: string[] = [];
|
|
438
470
|
for (const result of pendingUploadResults) {
|
|
439
471
|
for (const file of (result.files || [])) {
|
|
@@ -445,7 +477,7 @@ async function connectAndHandle(params: ConnectParams): Promise<void> {
|
|
|
445
477
|
}
|
|
446
478
|
}
|
|
447
479
|
if (uploadLinks.length > 0) {
|
|
448
|
-
finalText
|
|
480
|
+
finalText += `\n\n**文件下载链接(24小时有效):**\n${uploadLinks.join("\n")}`;
|
|
449
481
|
log?.info(`[adp-openclaw] Added ${uploadLinks.length} download links to final response`);
|
|
450
482
|
}
|
|
451
483
|
}
|