Skip to content

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

fix(agent): reject source platforms after leading non-social destinations

Emre Sokullueea43f93db10
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 8392ffee3..246b9c790 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -313,7 +313,7 @@ const SOCIAL_PUBLISH_DESTINATION_LEAD = new RegExp(
'iu',
);
-const NON_SOCIAL_DESTINATION_NOUNS = '(?:survey|form|questionnaire|poll|spreadsheet|sheet|doc|document|report|ticket|table|database|email|mail|inbox|slack|discord|notion|airtable|crm|system|file|input|field|box|website|portal|blog|formulario|formulaire|formular|encuesta|fragebogen|relat[oó]rio|rapport|bericht|tabela|tabelle|tableau|scheda|sondage|sondaggio|questionario|pesquisa|informe|postfach|buz[oó]n|bo[iî]te|casella|sitio|s[ií]tio|site|webseite|portale?|\u043e\u043f\u0440\u043e\u0441|\u0430\u043d\u043a\u0435\u0442\u0430|\u0444\u043e\u0440\u043c\u0430|\u0442\u0430\u0431\u043b\u0438\u0446\u0430|\u043e\u0442\u0447[e\u0451]\u0442|\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442|\u0444\u0430\u0439\u043b|\u043f\u043e\u0447\u0442\u0430|\u0441\u0430\u0439\u0442)';
+const NON_SOCIAL_DESTINATION_NOUNS = '(?:survey|form|questionnaire|poll|spreadsheet|sheet|doc|document|report|ticket|table|database|email|mail|inbox|slack|discord|notion|airtable|crm|system|file|input|field|box|website|portal|blog|formulario|formulaire|formular|encuesta|fragebogen|relat[oó]rio|rapport|bericht|tabela|tabelle|tableau|scheda|sondage|sondaggio|questionario|pesquisa|informe|postfach|buz[oó]n|bo[iî]te|casella|sitio|s[ií]tio|site|webseite|portale?|umfragen?|\u043e\u043f\u0440\u043e\u0441|\u0430\u043d\u043a\u0435\u0442\u0430|\u0444\u043e\u0440\u043c\u0430|\u0442\u0430\u0431\u043b\u0438\u0446\u0430|\u043e\u0442\u0447[e\u0451]\u0442|\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442|\u0444\u0430\u0439\u043b|\u043f\u043e\u0447\u0442\u0430|\u0441\u0430\u0439\u0442)';
const NON_SOCIAL_DESTINATION_PREPS = '(?:in|into|to|within|inside|through|en|dans|auf|em|para|su|sur|\u00e0|au|nel|nella|in\\s+der|im|\u0432|\u0432\\s+\u044d\u0442\u043e\u0442|\u043d\u0430)';
const NON_SOCIAL_DESTINATION_ARTICLES = '(?:the\\s+|an?\\s+|un\\s+|une\\s+|el\\s+|la\\s+|los\\s+|las\\s+|der\\s+|die\\s+|das\\s+|dem\\s+|den\\s+|o\\s+|a\\s+|os\\s+|as\\s+|il\\s+|lo\\s+|gli\\s+|le\\s+|d\\w*\\s+)?';
@@ -15608,7 +15608,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const verbWord = verb[0] || '';
const afterVerbText = targetText.slice(verbIndex + verbWord.length);
if (SOCIAL_POST_NEGATION.test(afterVerbText.trim())) continue;
- if (SOCIAL_NOUN_LIKE_PUBLISH.test(verbWord) && SOCIAL_READ_VERBS.test(afterVerbText)) continue;
+ if (SOCIAL_NOUN_LIKE_PUBLISH.test(verbWord) && (
+ SOCIAL_READ_VERBS.test(afterVerbText)
+ || /(?<![\p{L}\p{N}_])(?:of|about|regarding|concerning|sur|de|des|du|von|su|sobre|über|all|these|those|some|any|the|my|our|their|his|her|user's|recent|latest|past|old|new|more)\s+$/iu.test(beforeVerbClause)
+ || NON_SOCIAL_DESTINATION_IN_TEXT.test(beforeVerbClause)
+ )) continue;
if (/^shares?$/i.test(verbWord) && /(?<![\p{L}\p{N}_])(?:market|mind|revenue|profit|traffic|audience|wallet|fair|lion's|stock|equity|file|screen|time)\s+$/iu.test(beforeVerbClause)) continue;
const afterVerb = targetText.slice(verbIndex + verbWord.length);
const beforeVerb = targetText.slice(0, verbIndex);
@@ -15618,8 +15622,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const afterPlat = afterVerb.slice((matchAfter.index ?? 0) + matchAfter[0].length);
const isSourceOnly = SOURCE_MODIFIER_BEFORE_PLATFORM.test(beforePlat)
|| NON_SOCIAL_DESTINATION_AFTER_PLATFORM.test(afterPlat)
+ || (NON_SOCIAL_DESTINATION_IN_TEXT.test(beforePlat)
+ && !/(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+$/i.test(beforePlat))
|| ((TOPIC_NOUN_BEFORE_PLATFORM.test(beforePlat) || TOPIC_NOUN_AFTER_PLATFORM.test(afterPlat))
- && NON_SOCIAL_DESTINATION_IN_TEXT.test(afterPlat)
+ && (NON_SOCIAL_DESTINATION_IN_TEXT.test(afterPlat) || NON_SOCIAL_DESTINATION_IN_TEXT.test(beforePlat))
&& !/^\s*(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+/i.test(afterPlat));
if (!isSourceOnly) return true;
}
@@ -15630,6 +15636,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const isSourceOnly = SOURCE_MODIFIER_BEFORE_PLATFORM.test(beforePlat)
|| NON_SOCIAL_DESTINATION_AFTER_PLATFORM.test(afterPlat)
|| NON_SOCIAL_DESTINATION_IN_TEXT.test(afterVerb)
+ || (NON_SOCIAL_DESTINATION_IN_TEXT.test(beforePlat)
+ && !/(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+$/i.test(beforePlat))
|| ((TOPIC_NOUN_BEFORE_PLATFORM.test(beforePlat) || TOPIC_NOUN_AFTER_PLATFORM.test(afterPlat))
&& (NON_SOCIAL_DESTINATION_IN_TEXT.test(afterPlat) || NON_SOCIAL_DESTINATION_IN_TEXT.test(afterVerb))
&& !/^\s*(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+/i.test(afterPlat));
@@ -15649,6 +15657,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const afterPlat = pTargetText.slice((matchPrev.index ?? 0) + matchPrev[0].length);
const isSourceOnly = SOURCE_MODIFIER_BEFORE_PLATFORM.test(beforePlat)
|| NON_SOCIAL_DESTINATION_AFTER_PLATFORM.test(afterPlat)
+ || (NON_SOCIAL_DESTINATION_IN_TEXT.test(beforePlat)
+ && !/(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+$/i.test(beforePlat))
|| ((TOPIC_NOUN_BEFORE_PLATFORM.test(beforePlat) || TOPIC_NOUN_AFTER_PLATFORM.test(afterPlat))
&& NON_SOCIAL_DESTINATION_IN_TEXT.test(afterPlat)
&& !/^\s*(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+/i.test(afterPlat));
@@ -15680,6 +15690,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const afterPlat = nextTargetText.slice((matchNext.index ?? 0) + matchNext[0].length);
const isSourceOnly = SOURCE_MODIFIER_BEFORE_PLATFORM.test(beforePlat)
|| NON_SOCIAL_DESTINATION_AFTER_PLATFORM.test(afterPlat)
+ || (NON_SOCIAL_DESTINATION_IN_TEXT.test(beforePlat)
+ && !/(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+$/i.test(beforePlat))
|| ((TOPIC_NOUN_BEFORE_PLATFORM.test(beforePlat) || TOPIC_NOUN_AFTER_PLATFORM.test(afterPlat))
&& NON_SOCIAL_DESTINATION_IN_TEXT.test(afterPlat)
&& !/^\s*(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+/i.test(afterPlat));
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index dab070b3f..f54705f50 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -246,7 +246,7 @@ const SOCIAL_PUBLISH_DESTINATION_LEAD = new RegExp(
'iu',
);
-const NON_SOCIAL_DESTINATION_NOUNS = '(?:survey|form|questionnaire|poll|spreadsheet|sheet|doc|document|report|ticket|table|database|email|mail|inbox|slack|discord|notion|airtable|crm|system|file|input|field|box|website|portal|blog|formulario|formulaire|formular|encuesta|fragebogen|relat[oó]rio|rapport|bericht|tabela|tabelle|tableau|scheda|sondage|sondaggio|questionario|pesquisa|informe|postfach|buz[oó]n|bo[iî]te|casella|sitio|s[ií]tio|site|webseite|portale?|\u043e\u043f\u0440\u043e\u0441|\u0430\u043d\u043a\u0435\u0442\u0430|\u0444\u043e\u0440\u043c\u0430|\u0442\u0430\u0431\u043b\u0438\u0446\u0430|\u043e\u0442\u0447[e\u0451]\u0442|\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442|\u0444\u0430\u0439\u043b|\u043f\u043e\u0447\u0442\u0430|\u0441\u0430\u0439\u0442)';
+const NON_SOCIAL_DESTINATION_NOUNS = '(?:survey|form|questionnaire|poll|spreadsheet|sheet|doc|document|report|ticket|table|database|email|mail|inbox|slack|discord|notion|airtable|crm|system|file|input|field|box|website|portal|blog|formulario|formulaire|formular|encuesta|fragebogen|relat[oó]rio|rapport|bericht|tabela|tabelle|tableau|scheda|sondage|sondaggio|questionario|pesquisa|informe|postfach|buz[oó]n|bo[iî]te|casella|sitio|s[ií]tio|site|webseite|portale?|umfragen?|\u043e\u043f\u0440\u043e\u0441|\u0430\u043d\u043a\u0435\u0442\u0430|\u0444\u043e\u0440\u043c\u0430|\u0442\u0430\u0431\u043b\u0438\u0446\u0430|\u043e\u0442\u0447[e\u0451]\u0442|\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442|\u0444\u0430\u0439\u043b|\u043f\u043e\u0447\u0442\u0430|\u0441\u0430\u0439\u0442)';
const NON_SOCIAL_DESTINATION_PREPS = '(?:in|into|to|within|inside|through|en|dans|auf|em|para|su|sur|\u00e0|au|nel|nella|in\\s+der|im|\u0432|\u0432\\s+\u044d\u0442\u043e\u0442|\u043d\u0430)';
const NON_SOCIAL_DESTINATION_ARTICLES = '(?:the\\s+|an?\\s+|un\\s+|une\\s+|el\\s+|la\\s+|los\\s+|las\\s+|der\\s+|die\\s+|das\\s+|dem\\s+|den\\s+|o\\s+|a\\s+|os\\s+|as\\s+|il\\s+|lo\\s+|gli\\s+|le\\s+|d\\w*\\s+)?';
@@ -13408,7 +13408,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const verbWord = verb[0] || '';
const afterVerbText = targetText.slice(verbIndex + verbWord.length);
if (SOCIAL_POST_NEGATION.test(afterVerbText.trim())) continue;
- if (SOCIAL_NOUN_LIKE_PUBLISH.test(verbWord) && SOCIAL_READ_VERBS.test(afterVerbText)) continue;
+ if (SOCIAL_NOUN_LIKE_PUBLISH.test(verbWord) && (
+ SOCIAL_READ_VERBS.test(afterVerbText)
+ || /(?<![\p{L}\p{N}_])(?:of|about|regarding|concerning|sur|de|des|du|von|su|sobre|über|all|these|those|some|any|the|my|our|their|his|her|user's|recent|latest|past|old|new|more)\s+$/iu.test(beforeVerbClause)
+ || NON_SOCIAL_DESTINATION_IN_TEXT.test(beforeVerbClause)
+ )) continue;
if (/^shares?$/i.test(verbWord) && /(?<![\p{L}\p{N}_])(?:market|mind|revenue|profit|traffic|audience|wallet|fair|lion's|stock|equity|file|screen|time)\s+$/iu.test(beforeVerbClause)) continue;
const afterVerb = targetText.slice(verbIndex + verbWord.length);
const beforeVerb = targetText.slice(0, verbIndex);
@@ -13418,8 +13422,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const afterPlat = afterVerb.slice((matchAfter.index ?? 0) + matchAfter[0].length);
const isSourceOnly = SOURCE_MODIFIER_BEFORE_PLATFORM.test(beforePlat)
|| NON_SOCIAL_DESTINATION_AFTER_PLATFORM.test(afterPlat)
+ || (NON_SOCIAL_DESTINATION_IN_TEXT.test(beforePlat)
+ && !/(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+$/i.test(beforePlat))
|| ((TOPIC_NOUN_BEFORE_PLATFORM.test(beforePlat) || TOPIC_NOUN_AFTER_PLATFORM.test(afterPlat))
- && NON_SOCIAL_DESTINATION_IN_TEXT.test(afterPlat)
+ && (NON_SOCIAL_DESTINATION_IN_TEXT.test(afterPlat) || NON_SOCIAL_DESTINATION_IN_TEXT.test(beforePlat))
&& !/^\s*(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+/i.test(afterPlat));
if (!isSourceOnly) return true;
}
@@ -13430,6 +13436,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const isSourceOnly = SOURCE_MODIFIER_BEFORE_PLATFORM.test(beforePlat)
|| NON_SOCIAL_DESTINATION_AFTER_PLATFORM.test(afterPlat)
|| NON_SOCIAL_DESTINATION_IN_TEXT.test(afterVerb)
+ || (NON_SOCIAL_DESTINATION_IN_TEXT.test(beforePlat)
+ && !/(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+$/i.test(beforePlat))
|| ((TOPIC_NOUN_BEFORE_PLATFORM.test(beforePlat) || TOPIC_NOUN_AFTER_PLATFORM.test(afterPlat))
&& (NON_SOCIAL_DESTINATION_IN_TEXT.test(afterPlat) || NON_SOCIAL_DESTINATION_IN_TEXT.test(afterVerb))
&& !/^\s*(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+/i.test(afterPlat));
@@ -13449,6 +13457,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const afterPlat = pTargetText.slice((matchPrev.index ?? 0) + matchPrev[0].length);
const isSourceOnly = SOURCE_MODIFIER_BEFORE_PLATFORM.test(beforePlat)
|| NON_SOCIAL_DESTINATION_AFTER_PLATFORM.test(afterPlat)
+ || (NON_SOCIAL_DESTINATION_IN_TEXT.test(beforePlat)
+ && !/(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+$/i.test(beforePlat))
|| ((TOPIC_NOUN_BEFORE_PLATFORM.test(beforePlat) || TOPIC_NOUN_AFTER_PLATFORM.test(afterPlat))
&& NON_SOCIAL_DESTINATION_IN_TEXT.test(afterPlat)
&& !/^\s*(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+/i.test(afterPlat));
@@ -13480,6 +13490,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const afterPlat = nextTargetText.slice((matchNext.index ?? 0) + matchNext[0].length);
const isSourceOnly = SOURCE_MODIFIER_BEFORE_PLATFORM.test(beforePlat)
|| NON_SOCIAL_DESTINATION_AFTER_PLATFORM.test(afterPlat)
+ || (NON_SOCIAL_DESTINATION_IN_TEXT.test(beforePlat)
+ && !/(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+$/i.test(beforePlat))
|| ((TOPIC_NOUN_BEFORE_PLATFORM.test(beforePlat) || TOPIC_NOUN_AFTER_PLATFORM.test(afterPlat))
&& NON_SOCIAL_DESTINATION_IN_TEXT.test(afterPlat)
&& !/^\s*(?:and|und|et|e|y|ve|и|oder|or|as\s+well\s+as)\s+/i.test(afterPlat));
diff --git a/test/run.js b/test/run.js
index a54ac4317..1812dd8a4 100644
--- a/test/run.js
+++ b/test/run.js
@@ -86487,6 +86487,21 @@ test('social publication workflow follows the live X or Bluesky destination and
'report on X adoption without non-social destination should publish to X'],
['Publish on X and in the survey: Update', ['twitter'],
'coordinated publish on X and in survey should publish to X'],
+ // Leading non-social destinations followed by source platforms
+ ['Publish in the survey a summary of posts on X', [],
+ 'leading survey destination before summary of posts on X was treated as publish destination'],
+ ['Publish into the form a collection of updates on Bluesky', [],
+ 'leading form destination before collection of updates on Bluesky was treated as publish destination'],
+ ['Publica en la encuesta un resumen de publicaciones en X', [],
+ 'Spanish leading survey destination before summary of publications on X was treated as publish destination'],
+ ['Publie dans le formulaire un résumé des posts sur X', [],
+ 'French leading form destination before summary of posts on X was treated as publish destination'],
+ ['Veröffentliche in der Umfrage eine Zusammenfassung von Beiträgen auf X', [],
+ 'German leading survey destination before summary of posts on X was treated as publish destination'],
+ ['Publish in the survey and on X: Update', ['twitter'],
+ 'coordinated publish in survey and on X should publish to X'],
+ ['Publish into the form and to Bluesky: Update', ['bluesky'],
+ 'coordinated publish into form and to Bluesky should publish to Bluesky'],
]) {
assert.deepEqual(
[...agent._trustedSocialPublishTargetAdapters({ taskText })],