Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

fix(agent): tighten social attachment evidence, premium body comparison, and retweet routing

Emre Sokullu407c75328593
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 748bd18ee..66b16d335 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -226,7 +226,7 @@ const DEFAULT_OUTPUT_COST_PER_MILLION_USD = 15;
// them honest.
const SOCIAL_WORD_EDGE = '\\p{L}\\p{N}_';
const SOCIAL_PUBLISH_VERBS = new RegExp(
- `(?<![${SOCIAL_WORD_EDGE}])(?:post|posts|posted|posting|publish|publishes|published|publishing|tweet|tweets|tweeted|tweeting|retweet|retweets|skeet|skeets|share|shares|shared|sharing|publica|public\u00e1|publ\u00edcalo|publ\u00edcala|publicalo|publicala|publicar|publicas|publican|publique|publiquen|publiquem|publicando|posta|postar|comparte|compartir|compartilhe|compartilhar|publie|publier|publiez|publions|publi\u00e9e|publi\u00e9e|publi\u00e9|partage|partager|partagez|pubblica|pubblicare|pubblicate|condividi|condividere|ver\u00f6ffentliche|ver\u00f6ffentlichen|ver\u00f6ffentlicht|poste|posten|teile|teilen|yay\u0131nla|yay\u0131nlay\u0131n|yay\u0131mla|payla\u015f|payla\u015f\u0131n|\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439|\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439\u0442\u0435|\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c|\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439|\u043f\u043e\u0434\u0435\u043b\u0438\u0441\u044c|\u0437\u0430\u043f\u043e\u0441\u0442\u044c)(?![${SOCIAL_WORD_EDGE}])`
+ `(?<![${SOCIAL_WORD_EDGE}])(?:post|posts|posted|posting|publish|publishes|published|publishing|tweet|tweets|tweeted|tweeting|skeet|skeets|share|shares|shared|sharing|publica|public\u00e1|publ\u00edcalo|publ\u00edcala|publicalo|publicala|publicar|publicas|publican|publique|publiquen|publiquem|publicando|posta|postar|comparte|compartir|compartilhe|compartilhar|publie|publier|publiez|publions|publi\u00e9e|publi\u00e9e|publi\u00e9|partage|partager|partagez|pubblica|pubblicare|pubblicate|condividi|condividere|ver\u00f6ffentliche|ver\u00f6ffentlichen|ver\u00f6ffentlicht|poste|posten|teile|teilen|yay\u0131nla|yay\u0131nlay\u0131n|yay\u0131mla|payla\u015f|payla\u015f\u0131n|\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439|\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439\u0442\u0435|\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c|\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439|\u043f\u043e\u0434\u0435\u043b\u0438\u0441\u044c|\u0437\u0430\u043f\u043e\u0441\u0442\u044c)(?![${SOCIAL_WORD_EDGE}])`
+ '|\u6295\u7a3f\u3059\u308b|\u6295\u7a3f\u3057\u3066|\u6295\u7a3f\u3057|\u6295\u7a3f|\u30c4\u30a4\u30fc\u30c8\u3057\u3066|\u30c4\u30a4\u30fc\u30c8\u3057|\u30dd\u30b9\u30c8\u3057\u3066|\u30dd\u30b9\u30c8\u3057|\u53d1\u5e03|\u767c\u5e03|\u53d1\u5e16|\u767c\u5e16|\u53d1\u63a8|\u767c\u63a8|\u53d1\u9001\u63a8\u6587|\uac8c\uc2dc|\uc62c\ub824|\uc62c\ub9ac|\u0627\u0646\u0634\u0631|\u0646\u0634\u0631',
'iu',
);
@@ -1831,7 +1831,7 @@ export class Agent extends LoopDetector {
.filter(Boolean)
.join('\n');
try { text = text.normalize('NFKC'); } catch {}
- return text.length <= 20000 ? text : '';
+ return text.length <= 25000 ? text : '';
}
_workflowTerminalEvidenceMatchesState(state, record) {
@@ -2023,11 +2023,12 @@ export class Agent extends LoopDetector {
}))?.[0] || '';
}
- _workflowMetadataValue(value) {
+ _workflowMetadataValue(value, maxLength = 10000) {
let text = String(value ?? '').replace(/\r\n?/g, '\n')
.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, '');
try { text = text.normalize('NFKC'); } catch {}
- return text.trim().slice(0, 10000);
+ text = text.trim();
+ return (typeof maxLength === 'number' && maxLength > 0) ? text.slice(0, maxLength) : text;
}
// AX formatLine truncates values at 60 chars and appends '...', plus
@@ -2112,9 +2113,11 @@ export class Agent extends LoopDetector {
}
_workflowPublishedPayloadValueObserved(requirement, sources = {}) {
- const want = this._workflowMetadataValue(requirement?.value);
- if (!want) return false;
const field = requirement?.field;
+ const want = field === 'body'
+ ? this._workflowMetadataValue(requirement?.value, 0)
+ : this._workflowMetadataValue(requirement?.value);
+ if (!want) return false;
if (field === 'tag') {
const escaped = want.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
@@ -2139,7 +2142,9 @@ export class Agent extends LoopDetector {
return false;
}
- const pageText = this._workflowMetadataValue(sources.pageText);
+ const pageText = field === 'body'
+ ? this._workflowMetadataValue(sources.pageText, 0)
+ : this._workflowMetadataValue(sources.pageText);
if (pageText) {
if (pageText === want) return true;
const escaped = want.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
@@ -2149,8 +2154,12 @@ export class Agent extends LoopDetector {
if (Array.isArray(sources.inventory?.items)) {
for (const item of sources.inventory.items) {
- const itemVal = this._workflowMetadataValue(item?.value);
- const itemLabel = this._workflowMetadataValue(item?.label);
+ const itemVal = field === 'body'
+ ? this._workflowMetadataValue(item?.value, 0)
+ : this._workflowMetadataValue(item?.value);
+ const itemLabel = field === 'body'
+ ? this._workflowMetadataValue(item?.label, 0)
+ : this._workflowMetadataValue(item?.label);
if (itemVal === want || itemLabel === want) return true;
if (itemVal && this._workflowAxValueMatchesExpected(itemVal, want, item)) return true;
}
@@ -2303,13 +2312,7 @@ export class Agent extends LoopDetector {
if (matchesSpecific) return true;
- if (/\.(?:png|jpg|jpeg|gif|webp|mp4|mov|webm|mkv)$/i.test(normalized)) {
- return wantsVideo
- ? rawAttachments.some(att => attachmentType(att) === 'video' || /\.(?:mp4|mov|webm|mkv)/i.test(String(att?.src || '')))
- : rawAttachments.some(att => attachmentType(att) === 'image' || !/\.(?:mp4|mov|webm|mkv)/i.test(String(att?.src || '')));
- }
-
- return true;
+ return false;
}
_workflowGithubReleaseIdentityParts(identity) {
@@ -14840,7 +14843,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (publishesTo('(?:bluesky|bsky(?:\\.app)?)')) targets.add('bluesky');
if (publishesTo('(?:x|x\\.com|twitter(?:\\.com)?)')
// "tweet this" names its own destination.
- || /\b(?:tweet|retweet)\s+(?:this|that|it|the\s+following)\b/i.test(trustedContext)) {
+ || /\btweet\s+(?:this|that|it|the\s+following)\b/i.test(trustedContext)) {
targets.add('twitter');
}
return targets;
@@ -28341,11 +28344,20 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
} catch {}
return false;
};
+ const isLinkPreview = (node) => {
+ try {
+ const cardContainer = node.closest?.('[data-testid*="card.layout"]');
+ if (!cardContainer) return false;
+ if (node.closest?.('[data-testid="tweetPhoto"],[data-testid^="postImage"]')) return false;
+ return true;
+ } catch {}
+ return false;
+ };
const rawAttachments = mediaNodes.length
? mediaNodes
: Array.from(best.querySelectorAll?.(
'img, video, [data-testid="tweetPhoto"], [data-testid="videoPlayer"], [data-testid="videoComponent"], [data-testid^="postImage"], [data-testid="postGalleryImage"], [data-testid="contentHider-post"], [data-testid="card.layoutLarge.media"]'
- ) || []).filter(candidate => !isEmbedded(candidate) && !isAvatarOrEmoji(candidate));
+ ) || []).filter(candidate => !isEmbedded(candidate) && !isAvatarOrEmoji(candidate) && !isLinkPreview(candidate));
const attachments = rawAttachments.slice(0, 12).map(candidate => {
const tag = (candidate.tagName || '').toLowerCase();
const testId = typeof candidate.getAttribute === 'function' ? (candidate.getAttribute('data-testid') || '') : '';
diff --git a/src/chrome/src/agent/completion-invariant.js b/src/chrome/src/agent/completion-invariant.js
index 1a1e05652..44607de05 100644
--- a/src/chrome/src/agent/completion-invariant.js
+++ b/src/chrome/src/agent/completion-invariant.js
@@ -348,6 +348,16 @@ export function publicationResourceRecordRoot(link, identity, publicationResourc
} catch {}
return false;
};
+ const isLinkPreview = (node) => {
+ try {
+ const cardContainer = node.closest?.('[data-testid*="card.layout"]');
+ if (!cardContainer) return false;
+ // Images inside an uploaded-media wrapper are genuine, not previews.
+ if (node.closest?.('[data-testid="tweetPhoto"],[data-testid^="postImage"]')) return false;
+ return true;
+ } catch {}
+ return false;
+ };
return candidates.filter(node => {
const tag = (node.tagName || '').toLowerCase();
const testId = typeof node.getAttribute === 'function' ? (node.getAttribute('data-testid') || '') : '';
@@ -360,7 +370,7 @@ export function publicationResourceRecordRoot(link, identity, publicationResourc
&& !testId.includes('card.layoutLarge.media')) {
return false;
}
- return !isAvatarOrEmoji(node);
+ return !isAvatarOrEmoji(node) && !isLinkPreview(node);
}).slice(0, 12);
} catch {
return [];
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 02c4a61de..5a33ab59d 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -159,7 +159,7 @@ const STAGED_SCREENSHOT_REDACTION_MAX_REGIONS = 400;
// them honest.
const SOCIAL_WORD_EDGE = '\\p{L}\\p{N}_';
const SOCIAL_PUBLISH_VERBS = new RegExp(
- `(?<![${SOCIAL_WORD_EDGE}])(?:post|posts|posted|posting|publish|publishes|published|publishing|tweet|tweets|tweeted|tweeting|retweet|retweets|skeet|skeets|share|shares|shared|sharing|publica|public\u00e1|publ\u00edcalo|publ\u00edcala|publicalo|publicala|publicar|publicas|publican|publique|publiquen|publiquem|publicando|posta|postar|comparte|compartir|compartilhe|compartilhar|publie|publier|publiez|publions|publi\u00e9e|publi\u00e9e|publi\u00e9|partage|partager|partagez|pubblica|pubblicare|pubblicate|condividi|condividere|ver\u00f6ffentliche|ver\u00f6ffentlichen|ver\u00f6ffentlicht|poste|posten|teile|teilen|yay\u0131nla|yay\u0131nlay\u0131n|yay\u0131mla|payla\u015f|payla\u015f\u0131n|\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439|\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439\u0442\u0435|\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c|\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439|\u043f\u043e\u0434\u0435\u043b\u0438\u0441\u044c|\u0437\u0430\u043f\u043e\u0441\u0442\u044c)(?![${SOCIAL_WORD_EDGE}])`
+ `(?<![${SOCIAL_WORD_EDGE}])(?:post|posts|posted|posting|publish|publishes|published|publishing|tweet|tweets|tweeted|tweeting|skeet|skeets|share|shares|shared|sharing|publica|public\u00e1|publ\u00edcalo|publ\u00edcala|publicalo|publicala|publicar|publicas|publican|publique|publiquen|publiquem|publicando|posta|postar|comparte|compartir|compartilhe|compartilhar|publie|publier|publiez|publions|publi\u00e9e|publi\u00e9e|publi\u00e9|partage|partager|partagez|pubblica|pubblicare|pubblicate|condividi|condividere|ver\u00f6ffentliche|ver\u00f6ffentlichen|ver\u00f6ffentlicht|poste|posten|teile|teilen|yay\u0131nla|yay\u0131nlay\u0131n|yay\u0131mla|payla\u015f|payla\u015f\u0131n|\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439|\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439\u0442\u0435|\u043e\u043f\u0443\u0431\u043b\u0438\u043a\u043e\u0432\u0430\u0442\u044c|\u043f\u0443\u0431\u043b\u0438\u043a\u0443\u0439|\u043f\u043e\u0434\u0435\u043b\u0438\u0441\u044c|\u0437\u0430\u043f\u043e\u0441\u0442\u044c)(?![${SOCIAL_WORD_EDGE}])`
+ '|\u6295\u7a3f\u3059\u308b|\u6295\u7a3f\u3057\u3066|\u6295\u7a3f\u3057|\u6295\u7a3f|\u30c4\u30a4\u30fc\u30c8\u3057\u3066|\u30c4\u30a4\u30fc\u30c8\u3057|\u30dd\u30b9\u30c8\u3057\u3066|\u30dd\u30b9\u30c8\u3057|\u53d1\u5e03|\u767c\u5e03|\u53d1\u5e16|\u767c\u5e16|\u53d1\u63a8|\u767c\u63a8|\u53d1\u9001\u63a8\u6587|\uac8c\uc2dc|\uc62c\ub824|\uc62c\ub9ac|\u0627\u0646\u0634\u0631|\u0646\u0634\u0631',
'iu',
);
@@ -1545,7 +1545,7 @@ export class Agent extends LoopDetector {
.filter(Boolean)
.join('\n');
try { text = text.normalize('NFKC'); } catch {}
- return text.length <= 20000 ? text : '';
+ return text.length <= 25000 ? text : '';
}
_workflowTerminalEvidenceMatchesState(state, record) {
@@ -1737,11 +1737,12 @@ export class Agent extends LoopDetector {
}))?.[0] || '';
}
- _workflowMetadataValue(value) {
+ _workflowMetadataValue(value, maxLength = 10000) {
let text = String(value ?? '').replace(/\r\n?/g, '\n')
.replace(/[\u0000-\u0008\u000b\u000c\u000e-\u001f\u007f]/g, '');
try { text = text.normalize('NFKC'); } catch {}
- return text.trim().slice(0, 10000);
+ text = text.trim();
+ return (typeof maxLength === 'number' && maxLength > 0) ? text.slice(0, maxLength) : text;
}
// AX formatLine truncates values at 60 chars and appends '...', plus
@@ -1826,9 +1827,11 @@ export class Agent extends LoopDetector {
}
_workflowPublishedPayloadValueObserved(requirement, sources = {}) {
- const want = this._workflowMetadataValue(requirement?.value);
- if (!want) return false;
const field = requirement?.field;
+ const want = field === 'body'
+ ? this._workflowMetadataValue(requirement?.value, 0)
+ : this._workflowMetadataValue(requirement?.value);
+ if (!want) return false;
if (field === 'tag') {
const escaped = want.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
@@ -1853,7 +1856,9 @@ export class Agent extends LoopDetector {
return false;
}
- const pageText = this._workflowMetadataValue(sources.pageText);
+ const pageText = field === 'body'
+ ? this._workflowMetadataValue(sources.pageText, 0)
+ : this._workflowMetadataValue(sources.pageText);
if (pageText) {
if (pageText === want) return true;
const escaped = want.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
@@ -1863,8 +1868,12 @@ export class Agent extends LoopDetector {
if (Array.isArray(sources.inventory?.items)) {
for (const item of sources.inventory.items) {
- const itemVal = this._workflowMetadataValue(item?.value);
- const itemLabel = this._workflowMetadataValue(item?.label);
+ const itemVal = field === 'body'
+ ? this._workflowMetadataValue(item?.value, 0)
+ : this._workflowMetadataValue(item?.value);
+ const itemLabel = field === 'body'
+ ? this._workflowMetadataValue(item?.label, 0)
+ : this._workflowMetadataValue(item?.label);
if (itemVal === want || itemLabel === want) return true;
if (itemVal && this._workflowAxValueMatchesExpected(itemVal, want, item)) return true;
}
@@ -2017,13 +2026,7 @@ export class Agent extends LoopDetector {
if (matchesSpecific) return true;
- if (/\.(?:png|jpg|jpeg|gif|webp|mp4|mov|webm|mkv)$/i.test(normalized)) {
- return wantsVideo
- ? rawAttachments.some(att => attachmentType(att) === 'video' || /\.(?:mp4|mov|webm|mkv)/i.test(String(att?.src || '')))
- : rawAttachments.some(att => attachmentType(att) === 'image' || !/\.(?:mp4|mov|webm|mkv)/i.test(String(att?.src || '')));
- }
-
- return true;
+ return false;
}
_workflowGithubReleaseIdentityParts(identity) {
@@ -12640,7 +12643,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (publishesTo('(?:bluesky|bsky(?:\\.app)?)')) targets.add('bluesky');
if (publishesTo('(?:x|x\\.com|twitter(?:\\.com)?)')
// "tweet this" names its own destination.
- || /\b(?:tweet|retweet)\s+(?:this|that|it|the\s+following)\b/i.test(trustedContext)) {
+ || /\btweet\s+(?:this|that|it|the\s+following)\b/i.test(trustedContext)) {
targets.add('twitter');
}
return targets;
@@ -24814,11 +24817,20 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
} catch {}
return false;
};
+ const isLinkPreview = (node) => {
+ try {
+ const cardContainer = node.closest?.('[data-testid*="card.layout"]');
+ if (!cardContainer) return false;
+ if (node.closest?.('[data-testid="tweetPhoto"],[data-testid^="postImage"]')) return false;
+ return true;
+ } catch {}
+ return false;
+ };
const rawAttachments = mediaNodes.length
? mediaNodes
: Array.from(best.querySelectorAll?.(
'img, video, [data-testid="tweetPhoto"], [data-testid="videoPlayer"], [data-testid="videoComponent"], [data-testid^="postImage"], [data-testid="postGalleryImage"], [data-testid="contentHider-post"], [data-testid="card.layoutLarge.media"]'
- ) || []).filter(candidate => !isEmbedded(candidate) && !isAvatarOrEmoji(candidate));
+ ) || []).filter(candidate => !isEmbedded(candidate) && !isAvatarOrEmoji(candidate) && !isLinkPreview(candidate));
const attachments = rawAttachments.slice(0, 12).map(candidate => {
const tag = (candidate.tagName || '').toLowerCase();
const testId = typeof candidate.getAttribute === 'function' ? (candidate.getAttribute('data-testid') || '') : '';
diff --git a/src/firefox/src/agent/completion-invariant.js b/src/firefox/src/agent/completion-invariant.js
index 1a1e05652..44607de05 100644
--- a/src/firefox/src/agent/completion-invariant.js
+++ b/src/firefox/src/agent/completion-invariant.js
@@ -348,6 +348,16 @@ export function publicationResourceRecordRoot(link, identity, publicationResourc
} catch {}
return false;
};
+ const isLinkPreview = (node) => {
+ try {
+ const cardContainer = node.closest?.('[data-testid*="card.layout"]');
+ if (!cardContainer) return false;
+ // Images inside an uploaded-media wrapper are genuine, not previews.
+ if (node.closest?.('[data-testid="tweetPhoto"],[data-testid^="postImage"]')) return false;
+ return true;
+ } catch {}
+ return false;
+ };
return candidates.filter(node => {
const tag = (node.tagName || '').toLowerCase();
const testId = typeof node.getAttribute === 'function' ? (node.getAttribute('data-testid') || '') : '';
@@ -360,7 +370,7 @@ export function publicationResourceRecordRoot(link, identity, publicationResourc
&& !testId.includes('card.layoutLarge.media')) {
return false;
}
- return !isAvatarOrEmoji(node);
+ return !isAvatarOrEmoji(node) && !isLinkPreview(node);
}).slice(0, 12);
} catch {
return [];
diff --git a/test/run.js b/test/run.js
index 326338d3e..47ac45c53 100644
--- a/test/run.js
+++ b/test/run.js
@@ -24586,14 +24586,19 @@ test('publication resource records keep the owning social card when it embeds an
getAttribute: name => (name === 'data-testid' ? 'tweetPhoto' : (name === 'src' ? 'https://pbs.twimg.com/media/pic.jpg' : null)),
closest: () => null,
};
+ const linkPreviewNode = {
+ tagName: 'img',
+ getAttribute: name => (name === 'src' ? 'https://pbs.twimg.com/card_img/thumb.jpg' : null),
+ closest: selector => (selector.includes('card.layout') ? { testId: 'card.layoutLarge.media' } : null),
+ };
const mediaCard = {
innerText: 'post with image',
querySelectorAll: selector => (
String(selector).includes('img')
- ? [avatarNode, emojiNode, photoNode]
+ ? [avatarNode, emojiNode, linkPreviewNode, photoNode]
: [plainPermalink]
),
- contains: node => [plainPermalink, mediaCard, avatarNode, emojiNode, photoNode].includes(node),
+ contains: node => [plainPermalink, mediaCard, avatarNode, emojiNode, linkPreviewNode, photoNode].includes(node),
};
const mediaPermalink = {
...plainPermalink,
@@ -24602,7 +24607,7 @@ test('publication resource records keep the owning social card when it embeds an
const mediaRecord = invariant.publicationResourceRecordRoot(mediaPermalink, identity, identityOf);
assert.equal(mediaRecord.root, mediaCard);
assert.deepEqual(mediaRecord.attachments, [photoNode],
- `${label}: media attachments failed to include photo or failed to filter avatar/emoji`);
+ `${label}: media attachments failed to include photo or failed to filter avatar/emoji/link-preview`);
}
for (const [label, rel] of [
@@ -86179,6 +86184,12 @@ test('social publication workflow follows the live X or Bluesky destination and
'a Chinese read command was wrongly treated as a publish destination'],
['发布到xbox', [],
'a word containing x was wrongly treated as X platform'],
+ ['retweet this', [],
+ 'retweet this was wrongly treated as a publish destination'],
+ ['retweet that', [],
+ 'retweet that was wrongly treated as a publish destination'],
+ ['retweet it', [],
+ 'retweet it was wrongly treated as a publish destination'],
]) {
assert.deepEqual(
[...agent._trustedSocialPublishTargetAdapters({ taskText })],
@@ -86524,6 +86535,100 @@ test('X and Bluesky same-route publication accepts only one new permalink with t
submit,
), true, AgentClass.name + ': post with matching video attachment was rejected');
+ assert.equal(agent._workflowPublishedResourcePayloadMatch(
+ {
+ ...submit.workflowBinding,
+ metadataRequirements: [
+ ...submit.workflowBinding.metadataRequirements,
+ { field: 'attachment', value: 'quarterly-chart.png' },
+ ],
+ publishedResourceIdentity: fixture.expectedIdentity,
+ preDispatchPublicationAccountIdentity: fixture.accountIdentity,
+ preDispatchPublicationAccountIdentityComplete: true,
+ },
+ guard,
+ pageStateWithImage,
+ fixture.feedUrl,
+ submit,
+ ), false, AgentClass.name + ': wrong uploaded asset satisfied specific attachment requirement');
+
+ const pageStateWithSpecificImage = {
+ ...exactPageState,
+ workflowResourceRecords: [
+ {
+ ...exactPageState.workflowResourceRecords[0],
+ attachments: [
+ { type: 'image', src: 'https://pbs.twimg.com/media/quarterly-chart.png', alt: 'quarterly-chart.png' },
+ ],
+ },
+ ],
+ };
+ assert.equal(agent._workflowPublishedResourcePayloadMatch(
+ {
+ ...submit.workflowBinding,
+ metadataRequirements: [
+ ...submit.workflowBinding.metadataRequirements,
+ { field: 'attachment', value: 'quarterly-chart.png' },
+ ],
+ publishedResourceIdentity: fixture.expectedIdentity,
+ preDispatchPublicationAccountIdentity: fixture.accountIdentity,
+ preDispatchPublicationAccountIdentityComplete: true,
+ },
+ guard,
+ pageStateWithSpecificImage,
+ fixture.feedUrl,
+ submit,
+ ), true, AgentClass.name + ': post with matching specific attachment was rejected');
+
+ if (fixture.adapterName === 'twitter') {
+ const longBody1 = 'A'.repeat(10500) + ' first suffix';
+ const longBody2 = 'A'.repeat(10500) + ' second suffix';
+ const longBodyState = {
+ ...exactPageState,
+ workflowResourceRecords: [
+ {
+ ...exactPageState.workflowResourceRecords[0],
+ bodyText: longBody1,
+ text: 'WebBrain\n' + longBody1 + '\n2m',
+ },
+ ],
+ };
+ const longBodyMismatchState = {
+ ...exactPageState,
+ workflowResourceRecords: [
+ {
+ ...exactPageState.workflowResourceRecords[0],
+ bodyText: longBody2,
+ text: 'WebBrain\n' + longBody2 + '\n2m',
+ },
+ ],
+ };
+ const longBodyBinding = {
+ ...submit.workflowBinding,
+ metadataRequirements: [
+ { field: 'body', value: longBody1 },
+ ],
+ publishedResourceIdentity: fixture.expectedIdentity,
+ preDispatchPublicationAccountIdentity: fixture.accountIdentity,
+ preDispatchPublicationAccountIdentityComplete: true,
+ };
+ assert.equal(agent._workflowPublishedResourcePayloadMatch(
+ longBodyBinding,
+ guard,
+ longBodyState,
+ fixture.feedUrl,
+ submit,
+ ), true, AgentClass.name + ': full Premium body (>10k chars) was rejected');
+
+ assert.equal(agent._workflowPublishedResourcePayloadMatch(
+ longBodyBinding,
+ guard,
+ longBodyMismatchState,
+ fixture.feedUrl,
+ submit,
+ ), false, AgentClass.name + ': Premium body with mismatched suffix past 10k chars was accepted');
+ }
+
assert.equal(agent._workflowTerminalEvidenceFromDone(
tabId,
exactPageState,