Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
fix(social-publish): support alternative bridges and bare ranges
Barack Sokullu2c05faed43e4
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex b35699a51..24b1ab9c3 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -3155,15 +3155,15 @@ export class Agent extends LoopDetector {// than accidentally constraining every attachment in a mixed requirement.const rangeCountToken = '(?:\\d+|zero|one|two|three|four|five|six|seven|eight|nine|ten|a|an)';const boundedCountRangeRegex = new RegExp(- `\\b(?:between\\s+(${rangeCountToken})\\s+and\\s+(${rangeCountToken})|from\\s+(${rangeCountToken})\\s+to\\s+(${rangeCountToken}))`+ `\\b(?:between\\s+(${rangeCountToken})\\s+and\\s+(${rangeCountToken})|from\\s+(${rangeCountToken})\\s+to\\s+(${rangeCountToken})|(${rangeCountToken})\\s+to\\s+(${rangeCountToken}))`+ '\\s+(images?|photos?|pictures?|pics?|videos?|clips?|recordings?|gifs?|attachments?|files?|media|uploads?|items?|assets?)\\b','giu',);const boundedCountRanges = [...text.matchAll(boundedCountRangeRegex)].map(match => {- const minimumCount = parseCountWord(match[1] || match[3]);- const maximumCount = parseCountWord(match[2] || match[4]);- const noun = match[5] || '';+ const minimumCount = parseCountWord(match[1] || match[3] || match[5]);+ const maximumCount = parseCountWord(match[2] || match[4] || match[6]);+ const noun = match[7] || '';const kind = RAW_GIF_NOUN_REGEX.test(noun) ? 'gif': RAW_IMAGE_NOUN_REGEX.test(noun) ? 'image': RAW_VIDEO_NOUN_REGEX.test(noun) ? 'video'@@ -17556,7 +17556,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// Only list-shaped glue may sit between the two platform mentions. An// unrelated branch such as "X or report the blocker; also post on// Bluesky" contains `or`, but it does not coordinate the destinations.- const directAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:,\s*)?(?:(?:or|oder|ou|o|oppure|veya|ya\s+da|\u0438\u043b\u0438|\u043b\u0438\u0431\u043e)(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740))\s*(?:(?:post|publish|share|tweet|send|reply|respond)\s+(?:(?:this|that|it|the\s+following)\s+)?)?(?:(?:also\s+)?(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)\s+)?(?:the\s+)?$/iu;+ const directAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:,\s*)?(?:(?:or|oder|ou|o|oppure|veya|ya\s+da|\u0438\u043b\u0438|\u043b\u0438\u0431\u043e)(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740))\s*(?:alternatively\s+)?(?:(?:post|publish|share|tweet|send|reply|respond)\s+(?:(?:this|that|it|the\s+following)\s+)?)?(?:(?:also\s+)?(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)\s+)?(?:the\s+)?$/iu;const platformPattern = /(?:https?:\/\/(?:www\.)?(?:x\.com|twitter\.com|bsky\.app)(?:[/?#]|$)|(?<![\p{L}\p{N}_])(?:x|twitter|bluesky|bsky\.app)(?![\p{L}\p{N}_]))/giu;const texts = [guard?.taskText, guard?.approvedPlanAnchor].map(value => String(value || '').trim())diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex e63bfeb2b..4e7237c5c 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -2870,15 +2870,15 @@ export class Agent extends LoopDetector {// than accidentally constraining every attachment in a mixed requirement.const rangeCountToken = '(?:\\d+|zero|one|two|three|four|five|six|seven|eight|nine|ten|a|an)';const boundedCountRangeRegex = new RegExp(- `\\b(?:between\\s+(${rangeCountToken})\\s+and\\s+(${rangeCountToken})|from\\s+(${rangeCountToken})\\s+to\\s+(${rangeCountToken}))`+ `\\b(?:between\\s+(${rangeCountToken})\\s+and\\s+(${rangeCountToken})|from\\s+(${rangeCountToken})\\s+to\\s+(${rangeCountToken})|(${rangeCountToken})\\s+to\\s+(${rangeCountToken}))`+ '\\s+(images?|photos?|pictures?|pics?|videos?|clips?|recordings?|gifs?|attachments?|files?|media|uploads?|items?|assets?)\\b','giu',);const boundedCountRanges = [...text.matchAll(boundedCountRangeRegex)].map(match => {- const minimumCount = parseCountWord(match[1] || match[3]);- const maximumCount = parseCountWord(match[2] || match[4]);- const noun = match[5] || '';+ const minimumCount = parseCountWord(match[1] || match[3] || match[5]);+ const maximumCount = parseCountWord(match[2] || match[4] || match[6]);+ const noun = match[7] || '';const kind = RAW_GIF_NOUN_REGEX.test(noun) ? 'gif': RAW_IMAGE_NOUN_REGEX.test(noun) ? 'image': RAW_VIDEO_NOUN_REGEX.test(noun) ? 'video'@@ -15355,7 +15355,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// Only list-shaped glue may sit between the two platform mentions. An// unrelated branch such as "X or report the blocker; also post on// Bluesky" contains `or`, but it does not coordinate the destinations.- const directAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:,\s*)?(?:(?:or|oder|ou|o|oppure|veya|ya\s+da|\u0438\u043b\u0438|\u043b\u0438\u0431\u043e)(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740))\s*(?:(?:post|publish|share|tweet|send|reply|respond)\s+(?:(?:this|that|it|the\s+following)\s+)?)?(?:(?:also\s+)?(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)\s+)?(?:the\s+)?$/iu;+ const directAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:,\s*)?(?:(?:or|oder|ou|o|oppure|veya|ya\s+da|\u0438\u043b\u0438|\u043b\u0438\u0431\u043e)(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740))\s*(?:alternatively\s+)?(?:(?:post|publish|share|tweet|send|reply|respond)\s+(?:(?:this|that|it|the\s+following)\s+)?)?(?:(?:also\s+)?(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)\s+)?(?:the\s+)?$/iu;const platformPattern = /(?:https?:\/\/(?:www\.)?(?:x\.com|twitter\.com|bsky\.app)(?:[/?#]|$)|(?<![\p{L}\p{N}_])(?:x|twitter|bluesky|bsky\.app)(?![\p{L}\p{N}_]))/giu;const texts = [guard?.taskText, guard?.approvedPlanAnchor].map(value => String(value || '').trim())diff --git a/test/run.js b/test/run.jsindex a8b9a2443..b302fa020 100644--- a/test/run.js+++ b/test/run.js@@ -91239,6 +91239,10 @@ test('alternative social destinations require one verified publication, not ever...guard,taskText: 'Post this on X or post this on Bluesky.',}), true, AgentClass.name + ': repeated publish object broke a destination alternative');+ assert.equal(agent._socialPublishTargetsAreAlternatives({+ ...guard,+ taskText: 'Post this on X or alternatively on Bluesky.',+ }), true, AgentClass.name + ': alternatively adverb broke a destination choice');assert.equal(agent._socialPublishTargetsAreAlternatives({...guard,taskText: 'Post on X or post this update on Bluesky.',@@ -92951,6 +92955,19 @@ test('upper-bound attachment qualifiers verify as maximum counts', () => {assert.equal(agent._workflowSocialPublishedAttachmentObserved({ value: 'between one and two images' }, { attachments: [image(1), image(2), image(3)] }), false,AgentClass.name + ': three images exceeded the bounded range');+ const bareBoundedImages = agent._parseWorkflowAttachmentRequirement('one to two images');+ assert.deepEqual(bareBoundedImages.boundedCountRanges, [+ { minimumCount: 1, maximumCount: 2, kind: 'image' },+ ], AgentClass.name + ': bare attachment range was not preserved');+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(+ { value: 'one to two images' }, { attachments: [image(1)] }), true,+ AgentClass.name + ': one image should satisfy a bare one-to-two range');+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(+ { value: 'one to two images' }, { attachments: [image(1), image(2)] }), true,+ AgentClass.name + ': two images should satisfy a bare one-to-two range');+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(+ { value: 'one to two images' }, { attachments: [image(1), image(2), image(3)] }), false,+ AgentClass.name + ': three images exceeded the bare one-to-two range');assert.equal(agent._workflowSocialPublishedAttachmentObserved({ value: 'between one and two images or one video' }, { attachments: [video(1)] }), true,AgentClass.name + ': valid video alternative was rejected by the image range');