Skip to content

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

fix(agent): honor negated media types in mixed constraints and reject platforms as report topics

Emre Sokullu0f8d31a4e47d
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 5800c2fd2..8392ffee3 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -277,6 +277,9 @@ const GENERIC_ATTACHMENT_WORDS = new Set([
'enclosure', 'enclosures', 'document', 'documents', 'documento', 'documentos',
'a', 'an', 'the', 'of', 'in', 'with', 'some', 'any',
'and', 'or', 'plus', 'also', 'as', 'well',
+ 'no', 'not', 'without', 'zero', 'none',
+ 'sin', 'sans', 'sem', 'senza', 'ohne', 'kein', 'keine', 'keinen', 'aucun', 'aucune', 'ningun', 'ninguna', 'ningún', 'nenhum', 'nenhuma', 'nessun', 'nessuno', 'nessuna', 'nie', 'без', 'нет',
+ 'yok',
'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten',
'single', 'multiple', 'both',
'de', 'du', 'des', 'el', 'la', 'los', 'las', 'der', 'die', 'das', 'di', 'il', 'lo', 'gli', 'le',
@@ -300,7 +303,7 @@ const GENERIC_ATTACHMENT_WORDS = new Set([
'와', '과', '및', '그리고', '하고', '도',
]);
-const CJK_GENERIC_ATTACHMENT_REGEX = /^[0-9一二两三四五六七八九十添付画像写真動画メディア已上传附件图片照片视频媒体枚つの本张條条个個장에서의사진이미지포토동영상비디오영상클립움짤첨부파일미디어하나둘셋넷다섯한두세네일이삼사오개건편와과및그리고하고도\s\-_,.:;!?/\\()&+/]+$/u;
+const CJK_GENERIC_ATTACHMENT_REGEX = /^[0-9一二两三四五六七八九十添付画像写真動画メディア已上传附件图片照片视频媒体枚つの本张條条个個장에서의사진이미지포토동영상비디오영상클립움짤첨부파일미디어하나둘셋넷다섯한두세네일이삼사오개건편와과및그리고하고도无没有不带零なし無しゼロ없음안함\s\-_,.:;!?/\\()&+、,。;:/]+$/u;
// "On <url>, publish this" names a destination just as plainly as
// "publish this on <url>", but only when the URL is presented as a place.
@@ -332,6 +335,58 @@ const SOURCE_MODIFIER_BEFORE_PLATFORM = new RegExp(
'iu',
);
+const TOPIC_NOUN_BEFORE_PLATFORM = new RegExp(
+ '\\b(?:report|reports|article|articles|paper|papers|study|studies|analysis|analyses|summary|summaries|overview|notes?|findings?|stats?|statistics|metrics?|data|info|information|updates?|news|briefs?|reviews?|drafts?|memos?|pieces?|columns?|posts?|stories|story|feedback|discussion|commentary|presentation|deck|slides?|content|research|surveys?|polls?'
+ + '|informes?|reportes?|art[ií]culos?|estudios?|an[aá]lisis|res[uú]men(?:es)?|noticias|datos|investiga[cç][ií][oó]n(?:es)?'
+ + '|rapports?|articles?|[eé]tudes?|analyses?|r[eé]sum[eé]s?|actualit[eé]s?|donn[eé]es?|recherches?|sondages?'
+ + '|berichte?|studien?|analysen?|nachrichten|daten|umfragen?)\\b'
+ + '|\\b(?:of|about|regarding|concerning|sur|de|von|su|sobre|\\u00fcber)\\s+[^.?!;:\\n]*$',
+ 'iu',
+);
+
+const TOPIC_NOUN_AFTER_PLATFORM = new RegExp(
+ '^\\s*(?:adoption|usage|growth|metrics?|statistics|stats|analytics|trends?|features?|sentiment|engagement|activity|performance|traffic|users?|accounts?|behavior|behaviour|policies|policy|changes?|updates?|security|api|platform|ecosystem|community|content|posts?|data|adopci[oó]n|uso|tendencias|rendimiento|croissance|utilisation|tendances|performances)\\b',
+ 'iu',
+);
+
+const IMAGE_NEGATION_REGEX = new RegExp(
+ `(?<![${SOCIAL_WORD_EDGE}])(?:no|not|without|without\\s+any|0|zero|none|sin|sans|sem|senza|ohne|kein|keine|keinen|aucun|aucune|ningun|ningún|ninguna|nenhum|nenhuma|nessun|nessuno|nessuna|nie|без|нет)\\s+(?:any\\s+)?(?:images?|photos?|pictures?|pics?|fotos?|bilder?|imagen(?:es)?|imágenes|pièces?\\s+jointes?|изображени[яй]|фото(?:графий)?|resim|fotoğraf)(?![${SOCIAL_WORD_EDGE}])`
+ + `|(?:images?|photos?|pictures?|pics?|fotos?|bilder?|imagen(?:es)?|imágenes)\\s*:\\s*(?:none|no|0|zero|false)`
+ + `|(?:无|没有|不带|零个|0个|0)\\s*(?:图片|照片|圖片)`
+ + `|(?:图片|照片|圖片)\\s*(?:无|没有|为0|为零|0个|零个|0)`
+ + `|(?:なし|無し|ゼロ|0)\\s*(?:画像|写真)`
+ + `|(?:画像|写真)\\s*(?:なし|無し|ゼロ|0)`
+ + `|(?:없는|없음|0개|0)\\s*(?:사진|이미지|포토)`
+ + `|(?:사진|이미지|포토)\\s*(?:없음|안함|0개|0)`
+ + `|(?:resim|fotoğraf)\\s*(?:yok|olmadan|olmasın)`,
+ 'iu',
+);
+
+const VIDEO_NEGATION_REGEX = new RegExp(
+ `(?<![${SOCIAL_WORD_EDGE}])(?:no|not|without|without\\s+any|0|zero|none|sin|sans|sem|senza|ohne|kein|keine|keinen|aucun|aucune|ningun|ningún|ninguna|nenhum|nenhuma|nessun|nessuno|nessuna|nie|без|нет)\\s+(?:any\\s+)?(?:videos?|clips?|recordings?|vid[eé]os?|видео|video)(?![${SOCIAL_WORD_EDGE}])`
+ + `|(?:videos?|clips?|recordings?|vid[eé]os?)\\s*:\\s*(?:none|no|0|zero|false)`
+ + `|(?:无|没有|不带|零个|0个|0)\\s*(?:视频|影片)`
+ + `|(?:视频|影片)\\s*(?:无|没有|为0|为零|0个|零个|0)`
+ + `|(?:なし|無し|ゼロ|0)\\s*(?:動画)`
+ + `|(?:動画)\\s*(?:なし|無し|ゼロ|0)`
+ + `|(?:없는|없음|0개|0)\\s*(?:동영상|비디오|영상)`
+ + `|(?:동영상|비디오|영상)\\s*(?:없음|안함|0개|0)`
+ + `|(?:video)\\s*(?:yok|olmadan|olmasın)`,
+ 'iu',
+);
+
+const GIF_NEGATION_REGEX = new RegExp(
+ `(?<![${SOCIAL_WORD_EDGE}])(?:no|not|without|without\\s+any|0|zero|none|sin|sans|sem|senza|ohne|kein|keine|keinen|aucun|aucune|ningun|ningún|ninguna|nenhum|nenhuma|nessun|nessuno|nessuna|nie|без|нет)\\s+(?:any\\s+)?(?:gifs?|animated[-_ ]gifs?)(?![${SOCIAL_WORD_EDGE}])`
+ + `|(?:gifs?)\\s*:\\s*(?:none|no|0|zero|false)`
+ + `|(?:无|没有|不带|零个|0个|0)\\s*(?:动图|動圖)`
+ + `|(?:动图|動圖)\\s*(?:无|没有|为0|为零|0个|零个|0)`
+ + `|(?:なし|無し|ゼロ|0)\\s*(?:gif|動圖|动图)`
+ + `|(?:gif|動圖|动图)\\s*(?:なし|無し|ゼロ|0)`
+ + `|(?:없는|없음|0개|0)\\s*(?:움짤|gif)`
+ + `|(?:움짤|gif)\\s*(?:없음|안함|0개|0)`,
+ 'iu',
+);
+
const VISION_SUB_CALL_TIMEOUT_MS = 90_000;
const CONTENT_ACTION_TIMEOUT_MS = 60_000;
const CONTENT_ACTION_RESPONSE_GRACE_MS = 5_000;
@@ -2546,10 +2601,10 @@ export class Agent extends LoopDetector {
const nounSuffix = '(?:attachments?|files?|m[eéèê]dias?|m[ií]dia|medien|medios?|uploads?|images?|photos?|pictures?|pics?|videos?|clips?|recordings?|gifs?|fichiers?|pièces?|archivos?|adjuntos?|anexos?|allegat[oi]?|anhänge?|anhang|dateien?|вложений|вложения|фото(?:графий)?|изображений|видео|файлов)';
if (new RegExp(`^${negPrefix}\\s+${nounSuffix}$`, 'i').test(s)) return true;
if (new RegExp(`^(?:0|zero)\\s*${nounSuffix}?$`, 'i').test(s)) return true;
- if (/(?:无|没有|不带|零个|0个)\s*(?:附件|图片|照片|视频|媒体|文件)|(?:附件|图片|照片|视频|媒体|文件)\s*(?:无|没有|为0|为零)/i.test(s)) return true;
- if (/(?:添付|メディア|画像|写真|動画|ファイル)\s*(?:なし|無し|ゼロ|0)|(?:なし|無し)\s*(?:添付|メディア|画像|写真|動画|ファイル)/i.test(s)) return true;
- if (/(?:첨부|미디어|사진|동영상|영상|파일)\s*(?:없음|안함|0개|0)|(?:없는|없음)\s*(?:첨부|미디어|사진|동영상|영상|파일)/i.test(s)) return true;
- if (/(?:ek|medya|fotoğraf|resim|video)\s*(?:yok|olmadan|olmasın)/i.test(s)) return true;
+ if (/^(?:(?:无|没有|不带|零个|0个)\s*(?:附件|图片|照片|视频|媒体|文件)|(?:附件|图片|照片|视频|媒体|文件)\s*(?:无|没有|为0|为零))$/i.test(s)) return true;
+ if (/^(?:(?:添付|メディア|画像|写真|動画|ファイル)\s*(?:なし|無し|ゼロ|0)|(?:なし|無し)\s*(?:添付|メディア|画像|写真|動画|ファイル))$/i.test(s)) return true;
+ if (/^(?:(?:첨부|미디어|사진|동영상|영상|파일)\s*(?:없음|안함|0개|0)|(?:없는|없음)\s*(?:첨부|미디어|사진|동영상|영상|파일))$/i.test(s)) return true;
+ if (/^(?:ek|medya|fotoğraf|resim|video)\s*(?:yok|olmadan|olmasın)$/i.test(s)) return true;
return false;
}
@@ -2575,15 +2630,42 @@ export class Agent extends LoopDetector {
};
}
- const wantsGif = /\b(?:gif|gifs)\b|\.gif(?:[?#]|$)|(?:animated[-_ ]gif|動圖|动图|움짤)/i.test(text);
- const wantsVideo = wantsGif || /\b(?:video|videos|mp4|mov|webm|mkv|clip|clips|recording|recordings|vidéo|vidéos)\b|(?:動画|视频|影片|видео|동영상|비디오|영상)/i.test(text);
- const wantsImage = /\b(?:image|images|photo|photos|picture|pictures|pic|pics|png|jpg|jpeg|webp|foto|fotos|bild|bilder|imagen(?:es)?|imágenes)\b|(?:画像|写真|图片|照片|圖片|изображение|фото|사진|이미지|포토)/i.test(text);
+ const isImageNegated = IMAGE_NEGATION_REGEX.test(text);
+ const isVideoNegated = VIDEO_NEGATION_REGEX.test(text);
+ const isGifNegated = GIF_NEGATION_REGEX.test(text);
+
+ if (isImageNegated && isVideoNegated) {
+ return {
+ isGeneric: true,
+ isNegative: true,
+ wantsNone: true,
+ expectedCount: 0,
+ expectedImageCount: 0,
+ expectedVideoCount: 0,
+ hasExplicitImageCount: true,
+ hasExplicitVideoCount: true,
+ hasExplicitCardinality: true,
+ wantsImage: false,
+ wantsVideo: false,
+ wantsGif: false,
+ normalized: text,
+ };
+ }
+
+ const hasRawGif = /\b(?:gif|gifs)\b|\.gif(?:[?#]|$)|(?:animated[-_ ]gif|動圖|动图|움짤)/i.test(text);
+ const hasRawVideo = hasRawGif || /\b(?:video|videos|mp4|mov|webm|mkv|clip|clips|recording|recordings|vidéo|vidéos)\b|(?:動画|视频|影片|видео|동영상|비디오|영상)/i.test(text);
+ const hasRawImage = /\b(?:image|images|photo|photos|picture|pictures|pic|pics|png|jpg|jpeg|webp|foto|fotos|bild|bilder|imagen(?:es)?|imágenes)\b|(?:画像|写真|图片|照片|圖片|изображение|фото|사진|이미지|포토)/i.test(text);
+
+ const wantsGif = hasRawGif && !isGifNegated;
+ const wantsVideo = (hasRawVideo && !isVideoNegated) || wantsGif;
+ const wantsImage = hasRawImage && !isImageNegated;
const parseCountWord = (str) => {
if (!str) return 0;
const s = str.trim().toLowerCase();
if (/^\d+$/.test(s)) return parseInt(s, 10);
const wordToNum = {
+ zero: 0, '0': 0, cero: 0, 'zéro': 0, null: 0, 'ноль': 0, 'нуль': 0, '零': 0, 'なし': 0, '無し': 0, '없음': 0, '无': 0,
a: 1, an: 1, one: 1, single: 1, un: 1, une: 1, uno: 1, una: 1, ein: 1, eine: 1, einen: 1, einer: 1, um: 1, uma: 1,
'一': 1, один: 1, одна: 1, одно: 1,
'하나': 1, '한': 1, '일': 1,
@@ -2606,6 +2688,7 @@ export class Agent extends LoopDetector {
const s = str.trim().toLowerCase();
if (/^\d+$/.test(s)) return true;
const explicitWords = new Set([
+ 'zero', 'cero', 'zéro', 'null', 'ноль', 'нуль',
'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten',
'single', 'both',
'deux', 'trois', 'quatre', 'cinq',
@@ -2625,27 +2708,43 @@ export class Agent extends LoopDetector {
if (CJK_GENERIC_ATTACHMENT_REGEX.test(text)) {
isGeneric = true;
} else {
- const nonPunctuation = text.replace(/[\s\-_,.:;!?/\\()&+/]+/g, ' ').trim();
+ const nonPunctuation = text.replace(/[\s\-_,.:;!?/\\()&+、,。;:/]+/g, ' ').trim();
const words = nonPunctuation ? nonPunctuation.split(/\s+/) : [];
isGeneric = words.length > 0 && words.every(w => /^\d+$/.test(w) || GENERIC_ATTACHMENT_WORDS.has(w) || CJK_GENERIC_ATTACHMENT_REGEX.test(w));
}
- const countPrefix = '(?:\\d+|a|an|one|two|three|four|five|six|seven|eight|nine|ten|single|both|multiple|un|une|deux|trois|quatre|cinq|uno|una|unos|unas|dos|tres|cuatro|cinco|due|tre|quattro|cinque|ein|eine|einen|einer|zwei|drei|vier|fünf|um|uma|dois|duas|três|один|одна|одно|два|две|три|четыре|пять|[一二两三四五六七八九十]|하나|둘|셋|넷|다섯|한(?=\\s*(?:장|개|건|편|개의|장의))|두(?=\\s*(?:장|개|건|편|개의|장의))|세(?=\\s*(?:장|개|건|편|개의|장의))|네(?=\\s*(?:장|개|건|편|개의|장의))|[일이삼사오](?=\\s*(?:장|개|건|편|개의|장의)))';
- const countSeparator = '(?:^|[\\s,;+&/|]|(?:\\b(?:and|und|et|e|y)\\b\\s*)|[와과및])';
+ const countPrefix = '(?:\\d+|zero|cero|zéro|a|an|one|two|three|four|five|six|seven|eight|nine|ten|single|both|multiple|un|une|deux|trois|quatre|cinq|uno|una|unos|unas|dos|tres|cuatro|cinco|due|tre|quattro|cinque|ein|eine|einen|einer|zwei|drei|vier|fünf|um|uma|dois|duas|três|один|одна|одно|два|две|три|четыре|пять|[一二两三四五六七八九十]|하나|둘|셋|넷|다섯|한(?=\\s*(?:장|개|건|편|개의|장의))|두(?=\\s*(?:장|개|건|편|개의|장의))|세(?=\\s*(?:장|개|건|편|개의|장의))|네(?=\\s*(?:장|개|건|편|개의|장의))|[일이삼사오](?=\\s*(?:장|개|건|편|개의|장의)))';
+ const countSeparator = '(?:^|[\\s,;+&/|、,。;:]|(?:\\b(?:and|und|et|e|y)\\b\\s*)|[와과및])';
const imageCountMatch = isGeneric
- ? (text.match(new RegExp(`${countSeparator}(${countPrefix})\\s*(?:images?|photos?|pictures?|pics?|foto|fotos|bild|bilder|imagen(?:es)?|imágenes|画像|写真|图片|照片|圖片|изображение|фото|사진|이미지|포토)(?:\\s*(?:장|개|건))?`, 'i'))
- || text.match(/(?:사진|이미지|포토)\s*([0-9하나둘셋넷다섯]+|[한두세네일이삼사오](?=\\s*(?:장|개|건|편|개의|장의)))\s*(?:장|개|건)?/i))
+ ? (text.match(new RegExp(`${countSeparator}(${countPrefix})(?:\\s*(?:枚|つ|本|张|條|条|个|個|장|개|건|편))?\\s*(?:images?|photos?|pictures?|pics?|foto|fotos|bild|bilder|imagen(?:es)?|imágenes|画像|写真|图片|照片|圖片|изображение|фото|사진|이미지|포토)(?:\\s*(?:장|개|건))?`, 'i'))
+ || text.match(/(?:사진|이미지|포토)\s*([0-9하나둘셋넷다섯]+|[한두세네일이삼사오](?=\\s*(?:장|개|건|편|개의|장의)))\s*(?:장|개|건)?/i)
+ || text.match(/(?:画像|写真|图片|照片|圖片)\s*([0-9一二两三四五六七八九十]+)\s*(?:枚|つ|张|條|条|个|個)?/i))
: null;
- const expectedImageCount = imageCountMatch ? parseCountWord(imageCountMatch[1]) : 0;
- const hasExplicitImageCount = imageCountMatch ? isExplicitCountWord(imageCountMatch[1]) : false;
+ let expectedImageCount = 0;
+ let hasExplicitImageCount = false;
+ if (isImageNegated) {
+ expectedImageCount = 0;
+ hasExplicitImageCount = true;
+ } else if (imageCountMatch) {
+ expectedImageCount = parseCountWord(imageCountMatch[1]);
+ hasExplicitImageCount = isExplicitCountWord(imageCountMatch[1]);
+ }
const videoCountMatch = isGeneric
- ? (text.match(new RegExp(`${countSeparator}(${countPrefix})\\s*(?:videos?|clips?|recordings?|gifs?|animated[-_ ]gifs?|vidéo|vidéos|動画|视频|影片|видео|동영상|비디오|영상)(?:\\s*(?:개|편|건))?`, 'i'))
- || text.match(/(?:동영상|비디오|영상)\s*([0-9하나둘셋넷다섯]+|[한두세네일이삼사오](?=\\s*(?:장|개|건|편|개의|장의)))\s*(?:개|편|건)?/i))
+ ? (text.match(new RegExp(`${countSeparator}(${countPrefix})(?:\\s*(?:枚|つ|本|张|條|条|个|個|장|개|건|편))?\\s*(?:videos?|clips?|recordings?|gifs?|animated[-_ ]gifs?|vidéo|vidéos|動画|视频|影片|видео|동영상|비디오|영상)(?:\\s*(?:개|편|건))?`, 'i'))
+ || text.match(/(?:동영상|비디오|영상)\s*([0-9하나둘셋넷다섯]+|[한두세네일이삼사오](?=\\s*(?:장|개|건|편|개의|장의)))\s*(?:개|편|건)?/i)
+ || text.match(/(?:動画|视频|影片)\s*([0-9一二两三四五六七八九十]+)\s*(?:つ|本|個|个|條|条|편|개)?/i))
: null;
- const expectedVideoCount = videoCountMatch ? parseCountWord(videoCountMatch[1]) : 0;
- const hasExplicitVideoCount = videoCountMatch ? isExplicitCountWord(videoCountMatch[1]) : false;
+ let expectedVideoCount = 0;
+ let hasExplicitVideoCount = false;
+ if (isVideoNegated) {
+ expectedVideoCount = 0;
+ hasExplicitVideoCount = true;
+ } else if (videoCountMatch) {
+ expectedVideoCount = parseCountWord(videoCountMatch[1]);
+ hasExplicitVideoCount = isExplicitCountWord(videoCountMatch[1]);
+ }
let hasExplicitGenericCount = false;
let expectedCount = 1;
@@ -2656,6 +2755,10 @@ export class Agent extends LoopDetector {
expectedCount = expectedImageCount + (wantsVideo ? 1 : 0);
} else if (expectedVideoCount > 0) {
expectedCount = expectedVideoCount + (wantsImage ? 1 : 0);
+ } else if (wantsVideo && !wantsImage) {
+ expectedCount = expectedVideoCount > 0 ? expectedVideoCount : 1;
+ } else if (wantsImage && !wantsVideo) {
+ expectedCount = expectedImageCount > 0 ? expectedImageCount : 1;
} else {
const genericNounCountMatch = text.match(new RegExp(`${countSeparator}(${countPrefix})\\s+(?:attachments?|files?|media|uploads?|pieces?|items?|assets?|enclosures?|documents?|fichiers?|archivos?|dateien?|allegati?|anexos?|вложения?|вложение|첨부(?:파일)?|파일|미디어)`, 'i'))
|| text.match(new RegExp(`${countSeparator}(${countPrefix})\\s*(?:枚|つ|本|张|條|条|个|個|장|개|건|편)`, 'i'))
@@ -15515,8 +15618,9 @@ 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)
- || (/\b(?:of|about|regarding|concerning|sur|de|von|su|sobre)\s+[^.?!;:\n]*$/iu.test(beforePlat)
- && NON_SOCIAL_DESTINATION_IN_TEXT.test(afterPlat));
+ || ((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));
if (!isSourceOnly) return true;
}
@@ -15525,7 +15629,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const afterPlat = beforeVerb.slice((matchBefore.index ?? 0) + matchBefore[0].length);
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(afterVerb)
+ || ((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));
if (!isSourceOnly) return true;
}
@@ -15541,7 +15648,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const beforePlat = pTargetText.slice(0, matchPrev.index);
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_AFTER_PLATFORM.test(afterPlat)
+ || ((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));
if (!isSourceOnly) {
foundLeadingPlatform = true;
break;
@@ -15569,7 +15679,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const beforePlat = nextTargetText.slice(0, matchNext.index);
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_AFTER_PLATFORM.test(afterPlat)
+ || ((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));
if (!isSourceOnly) return true;
}
}
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 6ccb93563..dab070b3f 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -210,6 +210,9 @@ const GENERIC_ATTACHMENT_WORDS = new Set([
'enclosure', 'enclosures', 'document', 'documents', 'documento', 'documentos',
'a', 'an', 'the', 'of', 'in', 'with', 'some', 'any',
'and', 'or', 'plus', 'also', 'as', 'well',
+ 'no', 'not', 'without', 'zero', 'none',
+ 'sin', 'sans', 'sem', 'senza', 'ohne', 'kein', 'keine', 'keinen', 'aucun', 'aucune', 'ningun', 'ninguna', 'ningún', 'nenhum', 'nenhuma', 'nessun', 'nessuno', 'nessuna', 'nie', 'без', 'нет',
+ 'yok',
'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten',
'single', 'multiple', 'both',
'de', 'du', 'des', 'el', 'la', 'los', 'las', 'der', 'die', 'das', 'di', 'il', 'lo', 'gli', 'le',
@@ -233,7 +236,7 @@ const GENERIC_ATTACHMENT_WORDS = new Set([
'와', '과', '및', '그리고', '하고', '도',
]);
-const CJK_GENERIC_ATTACHMENT_REGEX = /^[0-9一二两三四五六七八九十添付画像写真動画メディア已上传附件图片照片视频媒体枚つの本张條条个個장에서의사진이미지포토동영상비디오영상클립움짤첨부파일미디어하나둘셋넷다섯한두세네일이삼사오개건편와과및그리고하고도\s\-_,.:;!?/\\()&+/]+$/u;
+const CJK_GENERIC_ATTACHMENT_REGEX = /^[0-9一二两三四五六七八九十添付画像写真動画メディア已上传附件图片照片视频媒体枚つの本张條条个個장에서의사진이미지포토동영상비디오영상클립움짤첨부파일미디어하나둘셋넷다섯한두세네일이삼사오개건편와과및그리고하고도无没有不带零なし無しゼロ없음안함\s\-_,.:;!?/\\()&+、,。;:/]+$/u;
// "On <url>, publish this" names a destination just as plainly as
// "publish this on <url>", but only when the URL is presented as a place.
@@ -265,6 +268,58 @@ const SOURCE_MODIFIER_BEFORE_PLATFORM = new RegExp(
'iu',
);
+const TOPIC_NOUN_BEFORE_PLATFORM = new RegExp(
+ '\\b(?:report|reports|article|articles|paper|papers|study|studies|analysis|analyses|summary|summaries|overview|notes?|findings?|stats?|statistics|metrics?|data|info|information|updates?|news|briefs?|reviews?|drafts?|memos?|pieces?|columns?|posts?|stories|story|feedback|discussion|commentary|presentation|deck|slides?|content|research|surveys?|polls?'
+ + '|informes?|reportes?|art[ií]culos?|estudios?|an[aá]lisis|res[uú]men(?:es)?|noticias|datos|investiga[cç][ií][oó]n(?:es)?'
+ + '|rapports?|articles?|[eé]tudes?|analyses?|r[eé]sum[eé]s?|actualit[eé]s?|donn[eé]es?|recherches?|sondages?'
+ + '|berichte?|studien?|analysen?|nachrichten|daten|umfragen?)\\b'
+ + '|\\b(?:of|about|regarding|concerning|sur|de|von|su|sobre|\\u00fcber)\\s+[^.?!;:\\n]*$',
+ 'iu',
+);
+
+const TOPIC_NOUN_AFTER_PLATFORM = new RegExp(
+ '^\\s*(?:adoption|usage|growth|metrics?|statistics|stats|analytics|trends?|features?|sentiment|engagement|activity|performance|traffic|users?|accounts?|behavior|behaviour|policies|policy|changes?|updates?|security|api|platform|ecosystem|community|content|posts?|data|adopci[oó]n|uso|tendencias|rendimiento|croissance|utilisation|tendances|performances)\\b',
+ 'iu',
+);
+
+const IMAGE_NEGATION_REGEX = new RegExp(
+ `(?<![${SOCIAL_WORD_EDGE}])(?:no|not|without|without\\s+any|0|zero|none|sin|sans|sem|senza|ohne|kein|keine|keinen|aucun|aucune|ningun|ningún|ninguna|nenhum|nenhuma|nessun|nessuno|nessuna|nie|без|нет)\\s+(?:any\\s+)?(?:images?|photos?|pictures?|pics?|fotos?|bilder?|imagen(?:es)?|imágenes|pièces?\\s+jointes?|изображени[яй]|фото(?:графий)?|resim|fotoğraf)(?![${SOCIAL_WORD_EDGE}])`
+ + `|(?:images?|photos?|pictures?|pics?|fotos?|bilder?|imagen(?:es)?|imágenes)\\s*:\\s*(?:none|no|0|zero|false)`
+ + `|(?:无|没有|不带|零个|0个|0)\\s*(?:图片|照片|圖片)`
+ + `|(?:图片|照片|圖片)\\s*(?:无|没有|为0|为零|0个|零个|0)`
+ + `|(?:なし|無し|ゼロ|0)\\s*(?:画像|写真)`
+ + `|(?:画像|写真)\\s*(?:なし|無し|ゼロ|0)`
+ + `|(?:없는|없음|0개|0)\\s*(?:사진|이미지|포토)`
+ + `|(?:사진|이미지|포토)\\s*(?:없음|안함|0개|0)`
+ + `|(?:resim|fotoğraf)\\s*(?:yok|olmadan|olmasın)`,
+ 'iu',
+);
+
+const VIDEO_NEGATION_REGEX = new RegExp(
+ `(?<![${SOCIAL_WORD_EDGE}])(?:no|not|without|without\\s+any|0|zero|none|sin|sans|sem|senza|ohne|kein|keine|keinen|aucun|aucune|ningun|ningún|ninguna|nenhum|nenhuma|nessun|nessuno|nessuna|nie|без|нет)\\s+(?:any\\s+)?(?:videos?|clips?|recordings?|vid[eé]os?|видео|video)(?![${SOCIAL_WORD_EDGE}])`
+ + `|(?:videos?|clips?|recordings?|vid[eé]os?)\\s*:\\s*(?:none|no|0|zero|false)`
+ + `|(?:无|没有|不带|零个|0个|0)\\s*(?:视频|影片)`
+ + `|(?:视频|影片)\\s*(?:无|没有|为0|为零|0个|零个|0)`
+ + `|(?:なし|無し|ゼロ|0)\\s*(?:動画)`
+ + `|(?:動画)\\s*(?:なし|無し|ゼロ|0)`
+ + `|(?:없는|없음|0개|0)\\s*(?:동영상|비디오|영상)`
+ + `|(?:동영상|비디오|영상)\\s*(?:없음|안함|0개|0)`
+ + `|(?:video)\\s*(?:yok|olmadan|olmasın)`,
+ 'iu',
+);
+
+const GIF_NEGATION_REGEX = new RegExp(
+ `(?<![${SOCIAL_WORD_EDGE}])(?:no|not|without|without\\s+any|0|zero|none|sin|sans|sem|senza|ohne|kein|keine|keinen|aucun|aucune|ningun|ningún|ninguna|nenhum|nenhuma|nessun|nessuno|nessuna|nie|без|нет)\\s+(?:any\\s+)?(?:gifs?|animated[-_ ]gifs?)(?![${SOCIAL_WORD_EDGE}])`
+ + `|(?:gifs?)\\s*:\\s*(?:none|no|0|zero|false)`
+ + `|(?:无|没有|不带|零个|0个|0)\\s*(?:动图|動圖)`
+ + `|(?:动图|動圖)\\s*(?:无|没有|为0|为零|0个|零个|0)`
+ + `|(?:なし|無し|ゼロ|0)\\s*(?:gif|動圖|动图)`
+ + `|(?:gif|動圖|动图)\\s*(?:なし|無し|ゼロ|0)`
+ + `|(?:없는|없음|0개|0)\\s*(?:움짤|gif)`
+ + `|(?:움짤|gif)\\s*(?:없음|안함|0개|0)`,
+ 'iu',
+);
+
const VISION_SUB_CALL_TIMEOUT_MS = 90_000;
const CONTENT_ACTION_TIMEOUT_MS = 60_000;
const CONTENT_ACTION_RESPONSE_GRACE_MS = 5_000;
@@ -2260,10 +2315,10 @@ export class Agent extends LoopDetector {
const nounSuffix = '(?:attachments?|files?|m[eéèê]dias?|m[ií]dia|medien|medios?|uploads?|images?|photos?|pictures?|pics?|videos?|clips?|recordings?|gifs?|fichiers?|pièces?|archivos?|adjuntos?|anexos?|allegat[oi]?|anhänge?|anhang|dateien?|вложений|вложения|фото(?:графий)?|изображений|видео|файлов)';
if (new RegExp(`^${negPrefix}\\s+${nounSuffix}$`, 'i').test(s)) return true;
if (new RegExp(`^(?:0|zero)\\s*${nounSuffix}?$`, 'i').test(s)) return true;
- if (/(?:无|没有|不带|零个|0个)\s*(?:附件|图片|照片|视频|媒体|文件)|(?:附件|图片|照片|视频|媒体|文件)\s*(?:无|没有|为0|为零)/i.test(s)) return true;
- if (/(?:添付|メディア|画像|写真|動画|ファイル)\s*(?:なし|無し|ゼロ|0)|(?:なし|無し)\s*(?:添付|メディア|画像|写真|動画|ファイル)/i.test(s)) return true;
- if (/(?:첨부|미디어|사진|동영상|영상|파일)\s*(?:없음|안함|0개|0)|(?:없는|없음)\s*(?:첨부|미디어|사진|동영상|영상|파일)/i.test(s)) return true;
- if (/(?:ek|medya|fotoğraf|resim|video)\s*(?:yok|olmadan|olmasın)/i.test(s)) return true;
+ if (/^(?:(?:无|没有|不带|零个|0个)\s*(?:附件|图片|照片|视频|媒体|文件)|(?:附件|图片|照片|视频|媒体|文件)\s*(?:无|没有|为0|为零))$/i.test(s)) return true;
+ if (/^(?:(?:添付|メディア|画像|写真|動画|ファイル)\s*(?:なし|無し|ゼロ|0)|(?:なし|無し)\s*(?:添付|メディア|画像|写真|動画|ファイル))$/i.test(s)) return true;
+ if (/^(?:(?:첨부|미디어|사진|동영상|영상|파일)\s*(?:없음|안함|0개|0)|(?:없는|없음)\s*(?:첨부|미디어|사진|동영상|영상|파일))$/i.test(s)) return true;
+ if (/^(?:ek|medya|fotoğraf|resim|video)\s*(?:yok|olmadan|olmasın)$/i.test(s)) return true;
return false;
}
@@ -2289,15 +2344,42 @@ export class Agent extends LoopDetector {
};
}
- const wantsGif = /\b(?:gif|gifs)\b|\.gif(?:[?#]|$)|(?:animated[-_ ]gif|動圖|动图|움짤)/i.test(text);
- const wantsVideo = wantsGif || /\b(?:video|videos|mp4|mov|webm|mkv|clip|clips|recording|recordings|vidéo|vidéos)\b|(?:動画|视频|影片|видео|동영상|비디오|영상)/i.test(text);
- const wantsImage = /\b(?:image|images|photo|photos|picture|pictures|pic|pics|png|jpg|jpeg|webp|foto|fotos|bild|bilder|imagen(?:es)?|imágenes)\b|(?:画像|写真|图片|照片|圖片|изображение|фото|사진|이미지|포토)/i.test(text);
+ const isImageNegated = IMAGE_NEGATION_REGEX.test(text);
+ const isVideoNegated = VIDEO_NEGATION_REGEX.test(text);
+ const isGifNegated = GIF_NEGATION_REGEX.test(text);
+
+ if (isImageNegated && isVideoNegated) {
+ return {
+ isGeneric: true,
+ isNegative: true,
+ wantsNone: true,
+ expectedCount: 0,
+ expectedImageCount: 0,
+ expectedVideoCount: 0,
+ hasExplicitImageCount: true,
+ hasExplicitVideoCount: true,
+ hasExplicitCardinality: true,
+ wantsImage: false,
+ wantsVideo: false,
+ wantsGif: false,
+ normalized: text,
+ };
+ }
+
+ const hasRawGif = /\b(?:gif|gifs)\b|\.gif(?:[?#]|$)|(?:animated[-_ ]gif|動圖|动图|움짤)/i.test(text);
+ const hasRawVideo = hasRawGif || /\b(?:video|videos|mp4|mov|webm|mkv|clip|clips|recording|recordings|vidéo|vidéos)\b|(?:動画|视频|影片|видео|동영상|비디오|영상)/i.test(text);
+ const hasRawImage = /\b(?:image|images|photo|photos|picture|pictures|pic|pics|png|jpg|jpeg|webp|foto|fotos|bild|bilder|imagen(?:es)?|imágenes)\b|(?:画像|写真|图片|照片|圖片|изображение|фото|사진|이미지|포토)/i.test(text);
+
+ const wantsGif = hasRawGif && !isGifNegated;
+ const wantsVideo = (hasRawVideo && !isVideoNegated) || wantsGif;
+ const wantsImage = hasRawImage && !isImageNegated;
const parseCountWord = (str) => {
if (!str) return 0;
const s = str.trim().toLowerCase();
if (/^\d+$/.test(s)) return parseInt(s, 10);
const wordToNum = {
+ zero: 0, '0': 0, cero: 0, 'zéro': 0, null: 0, 'ноль': 0, 'нуль': 0, '零': 0, 'なし': 0, '無し': 0, '없음': 0, '无': 0,
a: 1, an: 1, one: 1, single: 1, un: 1, une: 1, uno: 1, una: 1, ein: 1, eine: 1, einen: 1, einer: 1, um: 1, uma: 1,
'一': 1, один: 1, одна: 1, одно: 1,
'하나': 1, '한': 1, '일': 1,
@@ -2320,6 +2402,7 @@ export class Agent extends LoopDetector {
const s = str.trim().toLowerCase();
if (/^\d+$/.test(s)) return true;
const explicitWords = new Set([
+ 'zero', 'cero', 'zéro', 'null', 'ноль', 'нуль',
'one', 'two', 'three', 'four', 'five', 'six', 'seven', 'eight', 'nine', 'ten',
'single', 'both',
'deux', 'trois', 'quatre', 'cinq',
@@ -2339,27 +2422,43 @@ export class Agent extends LoopDetector {
if (CJK_GENERIC_ATTACHMENT_REGEX.test(text)) {
isGeneric = true;
} else {
- const nonPunctuation = text.replace(/[\s\-_,.:;!?/\\()&+/]+/g, ' ').trim();
+ const nonPunctuation = text.replace(/[\s\-_,.:;!?/\\()&+、,。;:/]+/g, ' ').trim();
const words = nonPunctuation ? nonPunctuation.split(/\s+/) : [];
isGeneric = words.length > 0 && words.every(w => /^\d+$/.test(w) || GENERIC_ATTACHMENT_WORDS.has(w) || CJK_GENERIC_ATTACHMENT_REGEX.test(w));
}
- const countPrefix = '(?:\\d+|a|an|one|two|three|four|five|six|seven|eight|nine|ten|single|both|multiple|un|une|deux|trois|quatre|cinq|uno|una|unos|unas|dos|tres|cuatro|cinco|due|tre|quattro|cinque|ein|eine|einen|einer|zwei|drei|vier|fünf|um|uma|dois|duas|três|один|одна|одно|два|две|три|четыре|пять|[一二两三四五六七八九十]|하나|둘|셋|넷|다섯|한(?=\\s*(?:장|개|건|편|개의|장의))|두(?=\\s*(?:장|개|건|편|개의|장의))|세(?=\\s*(?:장|개|건|편|개의|장의))|네(?=\\s*(?:장|개|건|편|개의|장의))|[일이삼사오](?=\\s*(?:장|개|건|편|개의|장의)))';
- const countSeparator = '(?:^|[\\s,;+&/|]|(?:\\b(?:and|und|et|e|y)\\b\\s*)|[와과및])';
+ const countPrefix = '(?:\\d+|zero|cero|zéro|a|an|one|two|three|four|five|six|seven|eight|nine|ten|single|both|multiple|un|une|deux|trois|quatre|cinq|uno|una|unos|unas|dos|tres|cuatro|cinco|due|tre|quattro|cinque|ein|eine|einen|einer|zwei|drei|vier|fünf|um|uma|dois|duas|três|один|одна|одно|два|две|три|четыре|пять|[一二两三四五六七八九十]|하나|둘|셋|넷|다섯|한(?=\\s*(?:장|개|건|편|개의|장의))|두(?=\\s*(?:장|개|건|편|개의|장의))|세(?=\\s*(?:장|개|건|편|개의|장의))|네(?=\\s*(?:장|개|건|편|개의|장의))|[일이삼사오](?=\\s*(?:장|개|건|편|개의|장의)))';
+ const countSeparator = '(?:^|[\\s,;+&/|、,。;:]|(?:\\b(?:and|und|et|e|y)\\b\\s*)|[와과및])';
const imageCountMatch = isGeneric
- ? (text.match(new RegExp(`${countSeparator}(${countPrefix})\\s*(?:images?|photos?|pictures?|pics?|foto|fotos|bild|bilder|imagen(?:es)?|imágenes|画像|写真|图片|照片|圖片|изображение|фото|사진|이미지|포토)(?:\\s*(?:장|개|건))?`, 'i'))
- || text.match(/(?:사진|이미지|포토)\s*([0-9하나둘셋넷다섯]+|[한두세네일이삼사오](?=\\s*(?:장|개|건|편|개의|장의)))\s*(?:장|개|건)?/i))
+ ? (text.match(new RegExp(`${countSeparator}(${countPrefix})(?:\\s*(?:枚|つ|本|张|條|条|个|個|장|개|건|편))?\\s*(?:images?|photos?|pictures?|pics?|foto|fotos|bild|bilder|imagen(?:es)?|imágenes|画像|写真|图片|照片|圖片|изображение|фото|사진|이미지|포토)(?:\\s*(?:장|개|건))?`, 'i'))
+ || text.match(/(?:사진|이미지|포토)\s*([0-9하나둘셋넷다섯]+|[한두세네일이삼사오](?=\\s*(?:장|개|건|편|개의|장의)))\s*(?:장|개|건)?/i)
+ || text.match(/(?:画像|写真|图片|照片|圖片)\s*([0-9一二两三四五六七八九十]+)\s*(?:枚|つ|张|條|条|个|個)?/i))
: null;
- const expectedImageCount = imageCountMatch ? parseCountWord(imageCountMatch[1]) : 0;
- const hasExplicitImageCount = imageCountMatch ? isExplicitCountWord(imageCountMatch[1]) : false;
+ let expectedImageCount = 0;
+ let hasExplicitImageCount = false;
+ if (isImageNegated) {
+ expectedImageCount = 0;
+ hasExplicitImageCount = true;
+ } else if (imageCountMatch) {
+ expectedImageCount = parseCountWord(imageCountMatch[1]);
+ hasExplicitImageCount = isExplicitCountWord(imageCountMatch[1]);
+ }
const videoCountMatch = isGeneric
- ? (text.match(new RegExp(`${countSeparator}(${countPrefix})\\s*(?:videos?|clips?|recordings?|gifs?|animated[-_ ]gifs?|vidéo|vidéos|動画|视频|影片|видео|동영상|비디오|영상)(?:\\s*(?:개|편|건))?`, 'i'))
- || text.match(/(?:동영상|비디오|영상)\s*([0-9하나둘셋넷다섯]+|[한두세네일이삼사오](?=\\s*(?:장|개|건|편|개의|장의)))\s*(?:개|편|건)?/i))
+ ? (text.match(new RegExp(`${countSeparator}(${countPrefix})(?:\\s*(?:枚|つ|本|张|條|条|个|個|장|개|건|편))?\\s*(?:videos?|clips?|recordings?|gifs?|animated[-_ ]gifs?|vidéo|vidéos|動画|视频|影片|видео|동영상|비디오|영상)(?:\\s*(?:개|편|건))?`, 'i'))
+ || text.match(/(?:동영상|비디오|영상)\s*([0-9하나둘셋넷다섯]+|[한두세네일이삼사오](?=\\s*(?:장|개|건|편|개의|장의)))\s*(?:개|편|건)?/i)
+ || text.match(/(?:動画|视频|影片)\s*([0-9一二两三四五六七八九十]+)\s*(?:つ|本|個|个|條|条|편|개)?/i))
: null;
- const expectedVideoCount = videoCountMatch ? parseCountWord(videoCountMatch[1]) : 0;
- const hasExplicitVideoCount = videoCountMatch ? isExplicitCountWord(videoCountMatch[1]) : false;
+ let expectedVideoCount = 0;
+ let hasExplicitVideoCount = false;
+ if (isVideoNegated) {
+ expectedVideoCount = 0;
+ hasExplicitVideoCount = true;
+ } else if (videoCountMatch) {
+ expectedVideoCount = parseCountWord(videoCountMatch[1]);
+ hasExplicitVideoCount = isExplicitCountWord(videoCountMatch[1]);
+ }
let hasExplicitGenericCount = false;
let expectedCount = 1;
@@ -2370,6 +2469,10 @@ export class Agent extends LoopDetector {
expectedCount = expectedImageCount + (wantsVideo ? 1 : 0);
} else if (expectedVideoCount > 0) {
expectedCount = expectedVideoCount + (wantsImage ? 1 : 0);
+ } else if (wantsVideo && !wantsImage) {
+ expectedCount = expectedVideoCount > 0 ? expectedVideoCount : 1;
+ } else if (wantsImage && !wantsVideo) {
+ expectedCount = expectedImageCount > 0 ? expectedImageCount : 1;
} else {
const genericNounCountMatch = text.match(new RegExp(`${countSeparator}(${countPrefix})\\s+(?:attachments?|files?|media|uploads?|pieces?|items?|assets?|enclosures?|documents?|fichiers?|archivos?|dateien?|allegati?|anexos?|вложения?|вложение|첨부(?:파일)?|파일|미디어)`, 'i'))
|| text.match(new RegExp(`${countSeparator}(${countPrefix})\\s*(?:枚|つ|本|张|條|条|个|個|장|개|건|편)`, 'i'))
@@ -13315,8 +13418,9 @@ 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)
- || (/\b(?:of|about|regarding|concerning|sur|de|von|su|sobre)\s+[^.?!;:\n]*$/iu.test(beforePlat)
- && NON_SOCIAL_DESTINATION_IN_TEXT.test(afterPlat));
+ || ((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));
if (!isSourceOnly) return true;
}
@@ -13325,7 +13429,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const afterPlat = beforeVerb.slice((matchBefore.index ?? 0) + matchBefore[0].length);
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(afterVerb)
+ || ((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));
if (!isSourceOnly) return true;
}
@@ -13341,7 +13448,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const beforePlat = pTargetText.slice(0, matchPrev.index);
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_AFTER_PLATFORM.test(afterPlat)
+ || ((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));
if (!isSourceOnly) {
foundLeadingPlatform = true;
break;
@@ -13369,7 +13479,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const beforePlat = nextTargetText.slice(0, matchNext.index);
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_AFTER_PLATFORM.test(afterPlat)
+ || ((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));
if (!isSourceOnly) return true;
}
}
diff --git a/test/run.js b/test/run.js
index ea89ec9d6..a54ac4317 100644
--- a/test/run.js
+++ b/test/run.js
@@ -86470,6 +86470,23 @@ test('social publication workflow follows the live X or Bluesky destination and
'leading platform before intervening clause was wrongly kept when publish command specifies survey destination'],
['Read posts on X. After reviewing the draft, publish it.', [],
'leading platform across sentence boundary was wrongly adopted'],
+ // Platform names used as report topics with non-social destinations
+ ['Publish a report on X adoption in the survey', [],
+ 'report on X adoption followed by survey destination was treated as publish destination'],
+ ['Publish a report on X in the survey', [],
+ 'report on X followed by survey destination was treated as publish destination'],
+ ['Publish a study on Bluesky usage in the spreadsheet', [],
+ 'study on Bluesky usage followed by spreadsheet destination was treated as publish destination'],
+ ['Publish research on X trends into the form', [],
+ 'research on X trends into form was treated as publish destination'],
+ ['Publica un informe sobre la adopción de X en la encuesta', [],
+ 'Spanish report on X adoption in survey was treated as publish destination'],
+ ['Publie un rapport sur l\'adoption de X dans le formulaire', [],
+ 'French report on X adoption in form was treated as publish destination'],
+ ['Publish a report on X adoption', ['twitter'],
+ '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'],
]) {
assert.deepEqual(
[...agent._trustedSocialPublishTargetAdapters({ taskText })],
@@ -88069,6 +88086,119 @@ test('attachment verification matches specific attachment names without substrin
AgentClass.name + `: post with attachment should reject "${negReq}"`
);
}
+
+ // Mixed positive and negative media types
+ const mixedCases = [
+ {
+ req: 'one video and no images',
+ valid: [{ type: 'video', src: 'https://video.twimg.com/clip.mp4' }],
+ invalidExtra: [
+ { type: 'video', src: 'https://video.twimg.com/clip.mp4' },
+ { type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' },
+ ],
+ invalidWrong: [{ type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' }],
+ },
+ {
+ req: '2 photos without video',
+ valid: [
+ { type: 'image', src: 'https://pbs.twimg.com/media/1.jpg' },
+ { type: 'image', src: 'https://pbs.twimg.com/media/2.jpg' },
+ ],
+ invalidExtra: [
+ { type: 'image', src: 'https://pbs.twimg.com/media/1.jpg' },
+ { type: 'image', src: 'https://pbs.twimg.com/media/2.jpg' },
+ { type: 'video', src: 'https://video.twimg.com/clip.mp4' },
+ ],
+ invalidWrong: [{ type: 'image', src: 'https://pbs.twimg.com/media/1.jpg' }],
+ },
+ {
+ req: '1 video, 0 images',
+ valid: [{ type: 'video', src: 'https://video.twimg.com/clip.mp4' }],
+ invalidExtra: [
+ { type: 'video', src: 'https://video.twimg.com/clip.mp4' },
+ { type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' },
+ ],
+ invalidWrong: [{ type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' }],
+ },
+ {
+ req: 'un video sin imágenes',
+ valid: [{ type: 'video', src: 'https://video.twimg.com/clip.mp4' }],
+ invalidExtra: [
+ { type: 'video', src: 'https://video.twimg.com/clip.mp4' },
+ { type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' },
+ ],
+ invalidWrong: [{ type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' }],
+ },
+ {
+ req: '1 vidéo sans photos',
+ valid: [{ type: 'video', src: 'https://video.twimg.com/clip.mp4' }],
+ invalidExtra: [
+ { type: 'video', src: 'https://video.twimg.com/clip.mp4' },
+ { type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' },
+ ],
+ invalidWrong: [{ type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' }],
+ },
+ {
+ req: '1 Video ohne Bilder',
+ valid: [{ type: 'video', src: 'https://video.twimg.com/clip.mp4' }],
+ invalidExtra: [
+ { type: 'video', src: 'https://video.twimg.com/clip.mp4' },
+ { type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' },
+ ],
+ invalidWrong: [{ type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' }],
+ },
+ {
+ req: '動画1つ、画像なし',
+ valid: [{ type: 'video', src: 'https://video.twimg.com/clip.mp4' }],
+ invalidExtra: [
+ { type: 'video', src: 'https://video.twimg.com/clip.mp4' },
+ { type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' },
+ ],
+ invalidWrong: [{ type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' }],
+ },
+ {
+ req: '동영상 1개, 사진 없음',
+ valid: [{ type: 'video', src: 'https://video.twimg.com/clip.mp4' }],
+ invalidExtra: [
+ { type: 'video', src: 'https://video.twimg.com/clip.mp4' },
+ { type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' },
+ ],
+ invalidWrong: [{ type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' }],
+ },
+ {
+ req: '1个视频,无图片',
+ valid: [{ type: 'video', src: 'https://video.twimg.com/clip.mp4' }],
+ invalidExtra: [
+ { type: 'video', src: 'https://video.twimg.com/clip.mp4' },
+ { type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' },
+ ],
+ invalidWrong: [{ type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' }],
+ },
+ {
+ req: 'no images, no videos',
+ valid: [],
+ invalidExtra: [{ type: 'image', src: 'https://pbs.twimg.com/media/pic.jpg' }],
+ invalidWrong: [{ type: 'video', src: 'https://video.twimg.com/clip.mp4' }],
+ },
+ ];
+
+ for (const { req, valid, invalidExtra, invalidWrong } of mixedCases) {
+ assert.equal(
+ agent._workflowSocialPublishedAttachmentObserved({ value: req }, { attachments: valid }),
+ true,
+ AgentClass.name + `: valid post should satisfy "${req}"`
+ );
+ assert.equal(
+ agent._workflowSocialPublishedAttachmentObserved({ value: req }, { attachments: invalidExtra }),
+ false,
+ AgentClass.name + `: post with extra forbidden media should reject "${req}"`
+ );
+ assert.equal(
+ agent._workflowSocialPublishedAttachmentObserved({ value: req }, { attachments: invalidWrong }),
+ false,
+ AgentClass.name + `: post with wrong media should reject "${req}"`
+ );
+ }
}
});