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): punctuated bodies, along-with grammar and destinations
Barack Sokullud7068f6df4cf
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 3424e67fc..eb37340d8 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -315,7 +315,7 @@ const GENERIC_ATTACHMENT_WORDS = new Set(['item', 'items', 'piece', 'pieces', 'upload', 'uploads', 'asset', 'assets','enclosure', 'enclosures', 'document', 'documents', 'documento', 'documentos','a', 'an', 'the', 'of', 'in', 'with', 'some', 'any',- 'and', 'but', 'or', 'either', 'neither', 'nor', 'plus', 'also', 'as', 'well', 'together', 'between', 'from', 'to',+ 'and', 'but', 'or', 'either', 'neither', 'nor', 'plus', 'also', 'as', 'well', 'together', 'along', 'between', 'from', 'to','no', 'not', 'without', 'zero', 'none','only', 'just', 'solely', 'exactly', 'exact', 'precisely','sin', 'sans', 'sem', 'senza', 'ohne', 'kein', 'keine', 'keinen', 'aucun', 'aucune', 'ningun', 'ninguna', 'ningún', 'nenhum', 'nenhuma', 'nessun', 'nessuno', 'nessuna', 'nie', 'без', 'нет',@@ -17945,7 +17945,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// matching would leave it unbound.const publishesTo = (platform) => {const destPreps = '(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)';- const coordConj = '(?:and|und|et|e|y|ve|и|oder|or|ou|o|plus|as\\s+well\\s+as|alongside|together\\s+with|&|\\/)';+ const coordConj = '(?:and|und|et|e|y|ve|и|oder|or|ou|o|plus|as\\s+well\\s+as|alongside|along\\s+with|together\\s+with|&|\\/)';const listModifiers = '(?:both|either|all|one\\s+of(?:\\s+the)?|ambos|ambas|entrambi|entrambe|beide|beiden|les\\s+deux|tous\\s+les\\s+deux|\u043e\u0431\u0430|\u043e\u0431\u0435|\u4e24\u8005|\u4e24\u4e2a|\u4e24|\u4e21\u65b9|\u4e21\u8005|\u4e21|\ub458\\s*\ub2e4|\ub458|\uc591\uc790|\uc591)';const coordItem = `(?:the\\s+)?(?:${listModifiers}\\s+)?[a-z0-9_.-]+(?:\\s+page|\\s+account|\\s+profile)?`;const coordPrefix = `(?:${coordItem}(?:\\s*,\\s*${coordItem})*\\s*(?:,\\s*${coordConj}|,|;|\\s+${coordConj})\\s+(?:the\\s+)?)`;@@ -26682,18 +26682,31 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst next = clauses[nextIndex];if ((next.delim || '').trim() === ':') {scoped += `:${next.text}`;- // Bodies may continue on following lines ("Post on X:\nhello- // \nworld"): newline clauses carry no terminator of their own,- // so they extend the same body unless a new publication clause- // for another destination begins.+ // Bodies may continue past the colon clause ("Post on X:\nhello+ // \nworld", "Post on X: hello, world"): following clauses extend+ // the same body until a new destination-specific publication+ // begins. Punctuation glue is reattached without padding so the+ // recovered text stays byte-faithful to the request.for (let bodyIndex = nextIndex + 1; bodyIndex < clauses.length; bodyIndex++) {const bodyClause = clauses[bodyIndex];- if ((bodyClause.delim || '') !== '') break;+ const bodyDelim = bodyClause.delim || '';+ if (bodyDelim === '') {+ const bodyMasked = bodyClause.maskedText || bodyClause.text || '';+ if (SOCIAL_PUBLISH_VERBS.test(bodyMasked)+ && anyPlatformPattern.test(bodyMasked)+ && !platformPattern.test(bodyMasked)) break;+ scoped += `\n${bodyClause.text}`;+ continue;+ }const bodyMasked = bodyClause.maskedText || bodyClause.text || '';- if (SOCIAL_PUBLISH_VERBS.test(bodyMasked)+ // A following destination with its own payload is a distinct+ // publication clause, not part of the current platform's body.+ if (SOCIAL_COORDINATING_DELIMITER.test(bodyDelim)&& anyPlatformPattern.test(bodyMasked)- && !platformPattern.test(bodyMasked)) break;- scoped += `\n${bodyClause.text}`;+ && (SOCIAL_PUBLISH_VERBS.test(bodyMasked) || hasQuotedPayload(bodyClause.text))) break;+ if (SOCIAL_PUBLISH_VERBS.test(bodyMasked)) break;+ if (/^[.!?;:,、,。;:]$/.test(bodyDelim)) scoped += `${bodyDelim}${bodyClause.text}`;+ else scoped += ` ${bodyDelim}${bodyClause.text}`;}break;}diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex aada4ad52..633d3b8d1 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -249,7 +249,7 @@ const GENERIC_ATTACHMENT_WORDS = new Set(['item', 'items', 'piece', 'pieces', 'upload', 'uploads', 'asset', 'assets','enclosure', 'enclosures', 'document', 'documents', 'documento', 'documentos','a', 'an', 'the', 'of', 'in', 'with', 'some', 'any',- 'and', 'but', 'or', 'either', 'neither', 'nor', 'plus', 'also', 'as', 'well', 'together', 'between', 'from', 'to',+ 'and', 'but', 'or', 'either', 'neither', 'nor', 'plus', 'also', 'as', 'well', 'together', 'along', 'between', 'from', 'to','no', 'not', 'without', 'zero', 'none','only', 'just', 'solely', 'exactly', 'exact', 'precisely','sin', 'sans', 'sem', 'senza', 'ohne', 'kein', 'keine', 'keinen', 'aucun', 'aucune', 'ningun', 'ninguna', 'ningún', 'nenhum', 'nenhuma', 'nessun', 'nessuno', 'nessuna', 'nie', 'без', 'нет',@@ -15744,7 +15744,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d// matching would leave it unbound.const publishesTo = (platform) => {const destPreps = '(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)';- const coordConj = '(?:and|und|et|e|y|ve|и|oder|or|ou|o|plus|as\\s+well\\s+as|alongside|together\\s+with|&|\\/)';+ const coordConj = '(?:and|und|et|e|y|ve|и|oder|or|ou|o|plus|as\\s+well\\s+as|alongside|along\\s+with|together\\s+with|&|\\/)';const listModifiers = '(?:both|either|all|one\\s+of(?:\\s+the)?|ambos|ambas|entrambi|entrambe|beide|beiden|les\\s+deux|tous\\s+les\\s+deux|\u043e\u0431\u0430|\u043e\u0431\u0435|\u4e24\u8005|\u4e24\u4e2a|\u4e24|\u4e21\u65b9|\u4e21\u8005|\u4e21|\ub458\\s*\ub2e4|\ub458|\uc591\uc790|\uc591)';const coordItem = `(?:the\\s+)?(?:${listModifiers}\\s+)?[a-z0-9_.-]+(?:\\s+page|\\s+account|\\s+profile)?`;const coordPrefix = `(?:${coordItem}(?:\\s*,\\s*${coordItem})*\\s*(?:,\\s*${coordConj}|,|;|\\s+${coordConj})\\s+(?:the\\s+)?)`;@@ -24289,18 +24289,31 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst next = clauses[nextIndex];if ((next.delim || '').trim() === ':') {scoped += `:${next.text}`;- // Bodies may continue on following lines ("Post on X:\nhello- // \nworld"): newline clauses carry no terminator of their own,- // so they extend the same body unless a new publication clause- // for another destination begins.+ // Bodies may continue past the colon clause ("Post on X:\nhello+ // \nworld", "Post on X: hello, world"): following clauses extend+ // the same body until a new destination-specific publication+ // begins. Punctuation glue is reattached without padding so the+ // recovered text stays byte-faithful to the request.for (let bodyIndex = nextIndex + 1; bodyIndex < clauses.length; bodyIndex++) {const bodyClause = clauses[bodyIndex];- if ((bodyClause.delim || '') !== '') break;+ const bodyDelim = bodyClause.delim || '';+ if (bodyDelim === '') {+ const bodyMasked = bodyClause.maskedText || bodyClause.text || '';+ if (SOCIAL_PUBLISH_VERBS.test(bodyMasked)+ && anyPlatformPattern.test(bodyMasked)+ && !platformPattern.test(bodyMasked)) break;+ scoped += `\n${bodyClause.text}`;+ continue;+ }const bodyMasked = bodyClause.maskedText || bodyClause.text || '';- if (SOCIAL_PUBLISH_VERBS.test(bodyMasked)+ // A following destination with its own payload is a distinct+ // publication clause, not part of the current platform's body.+ if (SOCIAL_COORDINATING_DELIMITER.test(bodyDelim)&& anyPlatformPattern.test(bodyMasked)- && !platformPattern.test(bodyMasked)) break;- scoped += `\n${bodyClause.text}`;+ && (SOCIAL_PUBLISH_VERBS.test(bodyMasked) || hasQuotedPayload(bodyClause.text))) break;+ if (SOCIAL_PUBLISH_VERBS.test(bodyMasked)) break;+ if (/^[.!?;:,、,。;:]$/.test(bodyDelim)) scoped += `${bodyDelim}${bodyClause.text}`;+ else scoped += ` ${bodyDelim}${bodyClause.text}`;}break;}diff --git a/test/run.js b/test/run.jsindex 1898abf5f..dc98a2af8 100644--- a/test/run.js+++ b/test/run.js@@ -91018,6 +91018,8 @@ test('social publication workflow follows the live X or Bluesky destination and'coordinated destinations on X and Bluesky should both be targeted'],['Post on X plus Bluesky', ['twitter', 'bluesky'],'coordinated destinations on X plus Bluesky should both be targeted'],+ ['Post on X along with Bluesky', ['twitter', 'bluesky'],+ 'coordinated destinations on X along with Bluesky should both be targeted'],['Post on X, then on Bluesky', ['twitter', 'bluesky'],'sequential destinations on X then Bluesky should both be targeted'],['Post on https://x.com/home, then on https://bsky.app/', ['twitter', 'bluesky'],@@ -91170,6 +91172,8 @@ test('social destination rebinding refreshes platform-specific payload and uploaAgentClass.name + ': multiline body after the colon was lost');assert.equal(agent._extractWorkflowTaskBody('Post on X: hello\nworld', '', 'twitter'), 'hello\nworld',AgentClass.name + ': body continuation line after inline colon text was lost');+ assert.equal(agent._extractWorkflowTaskBody('Post on X: hello, world', '', 'twitter'), 'hello, world',+ AgentClass.name + ': comma-delimited body text after the colon was lost');assert.equal(guard.workflowMetadataRequirementsResolved, true);assert.deepEqual(guard.workflowSocialUploadEvidence, [],AgentClass.name + ': X upload provenance leaked into the Bluesky binding');@@ -91361,6 +91365,7 @@ test('alternative social destinations require one verified publication, not ever'Post this on X alongside Bluesky.','Post this on X together with Bluesky.','Post on X plus Bluesky.',+ 'Post on X along with Bluesky.',]) {const conjunctiveList = { ...guard, taskText };assert.deepEqual(@@ -93200,6 +93205,11 @@ test('upper-bound attachment qualifiers verify as maximum counts', () => {assert.equal(agent._workflowSocialPublishedAttachmentObserved({ value: 'one image together with one video' }, { attachments: [image(1), video(1)] }), true,AgentClass.name + ': one image together with one video was rejected');+ assert.equal(agent._parseWorkflowAttachmentRequirement('one image along with one video').isGeneric, true,+ AgentClass.name + ': along-with conjunction was parsed as a filename');+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(+ { value: 'one image along with one video' }, { attachments: [image(1), video(1)] }), true,+ AgentClass.name + ': one image along with one video was rejected');const unrestrictedOrPngImage = agent._parseWorkflowAttachmentRequirement('one image or one PNG image');assert.equal(unrestrictedOrPngImage.mediaAlternativeBranches.length, 2,AgentClass.name + ': a format token consumed the noun slot of a whole-media alternative');