fix(wechat): complement page link delivery when reply references public html
Memind CI / Test, build, and release guards (push) Failing after 7s

Intent routing and reply content now both trigger HTML delivery: public links,
public/*.html paths, or html writes in the agent reply enable artifact recovery,
link attachment, and fail-closed when the claimed page is missing.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
john
2026-08-02 10:00:05 +08:00
parent 3e8cdfdda3
commit 3547cf8ef0
3 changed files with 227 additions and 16 deletions
+28 -3
View File
@@ -32,6 +32,31 @@ function replyMessages(reply) {
: [];
}
function messageVisibleText(message) {
if (!message?.content) return '';
return message.content
.filter((item) => item.type === 'text' && typeof item.text === 'string')
.map((item) => item.text)
.join('');
}
function collectReplyLinkScanText(reply) {
const parts = [];
const seen = new Set();
const append = (text) => {
const normalized = String(text ?? '').trim();
if (!normalized || seen.has(normalized)) return;
seen.add(normalized);
parts.push(normalized);
};
append(reply?.text);
for (const message of replyMessages(reply)) {
if (message?.role !== 'assistant') continue;
append(messageVisibleText(message));
}
return parts.join('\n');
}
function extractHtmlWriteTargets(messages = []) {
const targets = new Set();
for (const message of messages) {
@@ -396,7 +421,7 @@ export function prepareWechatHtmlDeliveryAtWorkspace({
? collectRecentArtifacts({
publishDir,
buildCanonicalUrl,
replyText: reply?.text,
replyText: collectReplyLinkScanText(reply),
requestStartedAt,
})
: [];
@@ -421,7 +446,7 @@ export function prepareWechatHtmlDeliveryAtWorkspace({
}) ?? artifact,
);
const linkedFilenames =
collectLinkedHtmlFilenames(reply?.text);
collectLinkedHtmlFilenames(collectReplyLinkScanText(reply));
const matchedArtifacts =
linkedFilenames.size > 0
? confirmedArtifacts.filter((artifact) =>
@@ -433,7 +458,7 @@ export function prepareWechatHtmlDeliveryAtWorkspace({
)
: confirmedArtifacts;
const validReplyUrls = buildValidReplyUrls(
reply?.text,
collectReplyLinkScanText(reply),
confirmedArtifacts,
);
return {