feat(wechat): channel split with stub-safe page delivery

Introduce wechat/ channel package; never send stub HTML links to service-account users.
This commit was merged in pull request #2.
This commit is contained in:
2026-07-04 05:21:13 +00:00
parent f36e8b9292
commit 2a3579c73a
8 changed files with 413 additions and 24 deletions
+54
View File
@@ -0,0 +1,54 @@
import { buildPagePublishFailureText } from '../prompts/page-generate.mjs';
import { selectSendableHtmlArtifacts, verifyPageArtifactContent } from '../verify/page-artifact.mjs';
export function evaluatePageGenerateSendableArtifacts({ verifiedArtifacts = [], confirmedArtifacts = [] } = {}) {
const sendable = selectSendableHtmlArtifacts({ verifiedArtifacts, confirmedArtifacts });
const verified = sendable.filter((artifact) => verifyPageArtifactContent(artifact).ok);
return verified.length > 0 ? verified : sendable;
}
/**
* Decide whether a page.generate reply may be delivered to the user.
* Returns { action: 'send'|'fail'|'session_retry', failureText?, reason? }
*/
export function resolvePageGenerateOutcome({
reply,
confirmedArtifacts = [],
verifiedArtifacts = [],
suspiciousPublishClaim = false,
bareCompletionReply = false,
htmlGenerationNeedsRetry = false,
replyHasPublicLinks = false,
}) {
const sendable = evaluatePageGenerateSendableArtifacts({ verifiedArtifacts, confirmedArtifacts });
if (sendable.length > 0) {
return { action: 'send', artifacts: sendable };
}
if (
suspiciousPublishClaim ||
bareCompletionReply ||
(htmlGenerationNeedsRetry && replyHasPublicLinks && confirmedArtifacts.length === 0)
) {
return { action: 'session_retry', reason: 'poisoned_or_fake_claim' };
}
if (htmlGenerationNeedsRetry || suspiciousPublishClaim) {
return {
action: 'fail',
failureText: buildPagePublishFailureText(),
reason: 'skill_or_stub',
};
}
if (!String(reply?.text ?? '').trim() && sendable.length === 0) {
return {
action: 'fail',
failureText: buildPagePublishFailureText(),
reason: 'empty_reply',
};
}
return { action: 'send', artifacts: sendable };
}