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): carry destination-first bodies and fallback alternatives
Barack Sokullu0b52d8c66edb
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 2385d2627..5ed58fa98 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -18114,8 +18114,8 @@ 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*(?:(?:alternatively|else)\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 explicitAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:,\s*)?(?:alternatively(?:\s+(?:on|onto|to|via|in|at))?|as\s+an\s+alternative\s+to)\s+(?:the\s+)?$/iu;+ const directAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:,\s*)?(?:(?:or|otherwise|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|otherwise|else)\s+)?(?:,\s*if\s+(?:unavailable|not\s+available|available|needed|necessary|possible|unable|unsuccessful|failing|failed|fails?|failure)\b[^,;]*,?\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 explicitAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:,\s*)?(?:(?:alternatively|otherwise)(?:\s+(?:on|onto|to|via|in|at))?|as\s+an\s+alternative\s+to)\s+(?:the\s+)?$/iu;const oneOfAlternativeLead = /(?<![\p{L}\p{N}_])one\s+of\s+(?:the\s+)?$/iu;const oneOfAlternativeBridge = /^\s*(?:,\s*)?(?:and|or)\s+(?:the\s+)?$/iu;const platformPattern = /(?:https?:\/\/(?:www\.)?(?:x\.com|twitter\.com|bsky\.app)(?:[/?#][^\s<>"'`\u3002\u3001\uff0c\uff1b\uff1a\uff01\uff1f\u2026\u2025]*|(?=[\s<>"'`\u3002\u3001\uff0c\uff1b\uff1a\uff01\uff1f\u2026\u2025,;!?]|$))|(?<![\p{L}\p{N}_])(?:x|twitter|bluesky|bsky\.app)(?![\p{L}\p{N}_]))/giu;@@ -26639,6 +26639,20 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dscoped += ` ${next.delim} ${next.text}`;continue;}+ // Destination-first: "On X, publish: <body>" carries no publish+ // verb in the platform clause, so a following comma/coordinated+ // publish clause without an alien platform belongs to the same+ // candidate and lets the colon body append on the next iteration.+ if (SOCIAL_PUBLISH_VERBS.test(next.maskedText || next.text || '')+ && (!anyPlatformPattern.test(next.maskedText || next.text || '')+ || platformPattern.test(next.maskedText || next.text || ''))+ && ((next.delim || '').trim() === ','+ || (next.delim || '').trim() === '、'+ || SOCIAL_COORDINATING_DELIMITER.test(next.delim || '')+ || SOCIAL_SEQUENTIAL_DELIMITER.test(next.delim || ''))) {+ scoped += ` ${next.delim} ${next.text}`;+ continue;+ }break;}scopedCandidates.push(scoped);diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 444a94ccf..2307048ed 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -15913,8 +15913,8 @@ 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*(?:(?:alternatively|else)\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 explicitAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:,\s*)?(?:alternatively(?:\s+(?:on|onto|to|via|in|at))?|as\s+an\s+alternative\s+to)\s+(?:the\s+)?$/iu;+ const directAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:,\s*)?(?:(?:or|otherwise|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|otherwise|else)\s+)?(?:,\s*if\s+(?:unavailable|not\s+available|available|needed|necessary|possible|unable|unsuccessful|failing|failed|fails?|failure)\b[^,;]*,?\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 explicitAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:,\s*)?(?:(?:alternatively|otherwise)(?:\s+(?:on|onto|to|via|in|at))?|as\s+an\s+alternative\s+to)\s+(?:the\s+)?$/iu;const oneOfAlternativeLead = /(?<![\p{L}\p{N}_])one\s+of\s+(?:the\s+)?$/iu;const oneOfAlternativeBridge = /^\s*(?:,\s*)?(?:and|or)\s+(?:the\s+)?$/iu;const platformPattern = /(?:https?:\/\/(?:www\.)?(?:x\.com|twitter\.com|bsky\.app)(?:[/?#][^\s<>"'`\u3002\u3001\uff0c\uff1b\uff1a\uff01\uff1f\u2026\u2025]*|(?=[\s<>"'`\u3002\u3001\uff0c\uff1b\uff1a\uff01\uff1f\u2026\u2025,;!?]|$))|(?<![\p{L}\p{N}_])(?:x|twitter|bluesky|bsky\.app)(?![\p{L}\p{N}_]))/giu;@@ -24246,6 +24246,20 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dscoped += ` ${next.delim} ${next.text}`;continue;}+ // Destination-first: "On X, publish: <body>" carries no publish+ // verb in the platform clause, so a following comma/coordinated+ // publish clause without an alien platform belongs to the same+ // candidate and lets the colon body append on the next iteration.+ if (SOCIAL_PUBLISH_VERBS.test(next.maskedText || next.text || '')+ && (!anyPlatformPattern.test(next.maskedText || next.text || '')+ || platformPattern.test(next.maskedText || next.text || ''))+ && ((next.delim || '').trim() === ','+ || (next.delim || '').trim() === '、'+ || SOCIAL_COORDINATING_DELIMITER.test(next.delim || '')+ || SOCIAL_SEQUENTIAL_DELIMITER.test(next.delim || ''))) {+ scoped += ` ${next.delim} ${next.text}`;+ continue;+ }break;}scopedCandidates.push(scoped);diff --git a/test/run.js b/test/run.jsindex fc4a2459e..c322167a4 100644--- a/test/run.js+++ b/test/run.js@@ -91154,6 +91154,12 @@ test('social destination rebinding refreshes platform-specific payload and uploaAgentClass.name + ': Bluesky-specific payload contaminated the X body');assert.equal(agent._extractWorkflowTaskBody('Post on X and "Bluesky only" on Bluesky', '', 'bluesky'), 'Bluesky only',AgentClass.name + ': Bluesky-specific payload was not recovered');+ assert.equal(agent._extractWorkflowTaskBody('On X, publish: Launch now', '', 'twitter'), 'Launch now',+ AgentClass.name + ': destination-first publish clause lost the X body');+ assert.equal(agent._extractWorkflowTaskBody('On X and Bluesky, publish: Launch now', '', 'twitter'), 'Launch now',+ AgentClass.name + ': destination-first publish clause lost the shared X body');+ assert.equal(agent._extractWorkflowTaskBody('On X and Bluesky, publish: Launch now', '', 'bluesky'), 'Launch now',+ AgentClass.name + ': destination-first publish clause lost the shared Bluesky body');assert.equal(guard.workflowMetadataRequirementsResolved, true);assert.deepEqual(guard.workflowSocialUploadEvidence, [],AgentClass.name + ': X upload provenance leaked into the Bluesky binding');@@ -91329,6 +91335,14 @@ test('alternative social destinations require one verified publication, not ever...guard,taskText: 'Post on X or else Bluesky.',}), true, AgentClass.name + ': or-else bridge turned alternative destinations into two mandatory posts');+ assert.equal(agent._socialPublishTargetsAreAlternatives({+ ...guard,+ taskText: 'Post on X, otherwise post on Bluesky.',+ }), true, AgentClass.name + ': otherwise fallback turned alternative destinations into two mandatory posts');+ assert.equal(agent._socialPublishTargetsAreAlternatives({+ ...guard,+ taskText: 'Post on X or, if unavailable, Bluesky.',+ }), true, AgentClass.name + ': conditional fallback turned alternative destinations into two mandatory posts');for (const taskText of ['Post this on X alongside Bluesky.','Post this on X together with Bluesky.',