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): colon scope, metadata shape, standalone fallbacks
Barack Sokullue6e7312b9841
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 0786a23f9..037f5d367 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -17975,7 +17975,15 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}}}- const governed = (isComposer && !firstAfterClause?.isNegated)+ // A composer opened under an explicit publish prohibition ("Do not+ // publish anything; open <composer> to inspect it") is for reading,+ // not posting: the prohibition anywhere in the trusted context vetoes+ // the verb-free composer shortcut (an affirmative publish command still+ // governs through the other arms below).+ const hasPublishProhibition = clauses.some(clause => (+ clause.isNegated && SOCIAL_PUBLISH_VERBS.test(clause.maskedText || clause.text || '')+ ));+ const governed = (isComposer && !firstAfterClause?.isNegated && !hasPublishProhibition)|| publishGoverned|| (SOCIAL_PUBLISH_DESTINATION_LEAD.test(lastBeforeClause?.text || '')&& this._socialPublicationCommandIn(firstAfterClause?.text || ''));@@ -26814,7 +26822,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d&& ((SOCIAL_COORDINATING_DELIMITER.test(following.delim || '')&& anyPlatformPattern.test(following.maskedText || following.text || ''))|| startsNewPublication(following.maskedText || following.text || ''));- if (!followingStartsDestination) {+ // A sequential step ("Then let me know...") is a new+ // instruction either way, so its glue is dropped too.+ const followingStartsSequence = following+ && SOCIAL_SEQUENTIAL_DELIMITER.test(following.delim || '');+ if (!followingStartsDestination && !followingStartsSequence) {if (/^[.!?;:,、,。;:]$/.test(bodyDelim)) scoped += bodyDelim;else if (bodyDelim) scoped += ` ${bodyDelim}`;}@@ -26835,6 +26847,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (SOCIAL_COORDINATING_DELIMITER.test(bodyDelim)&& anyPlatformPattern.test(bodyMasked)) break;if (startsNewPublication(bodyMasked)) break;+ // A sequential step ("Then let me know when it is done")+ // starts a new instruction, not body prose.+ if (SOCIAL_SEQUENTIAL_DELIMITER.test(bodyDelim)) break;if (/^[.!?;:,、,。;:]$/.test(bodyDelim)) scoped += `${bodyDelim}${bodyClause.text}`;else scoped += ` ${bodyDelim}${bodyClause.text}`;}@@ -27101,8 +27116,21 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (extractedBody) {const bodyReq = details.items.find(r => r.field === 'body');if (bodyReq) {+ // An operational follow-up ("Then let me know when it is done")+ // is not post prose: replace an explicit placeholder, an exact+ // match, or a truncation the extraction identifiably continues+ // (the classified value ends mid-token and the extraction+ // carries that same token on). A value ending at a word+ // boundary is complete as stated and never grows.+ const normalizedExtracted = this._workflowMetadataValue(extractedBody);+ const normalizedClassified = this._workflowMetadataValue(bodyReq.value);+ const continuationIndex = normalizedExtracted.indexOf(normalizedClassified);+ const continuesMidWord = normalizedClassified.length > 0 && continuationIndex >= 0+ && /[\p{L}\p{N}_]$/u.test(normalizedClassified)+ && /^[\p{L}\p{N}_]/u.test(normalizedExtracted.slice(continuationIndex + normalizedClassified.length));if (bodyReq.value === '[from task]'- || extractedBody.includes(bodyReq.value)) {+ || normalizedExtracted === normalizedClassified+ || continuesMidWord) {bodyReq.value = this._workflowMetadataValue(extractedBody, 25000);}} else if (siteWorkflow?.job?.id === 'publish-post' || siteWorkflow?.job?.id === 'publish-content') {diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 66943072d..5a484e3a4 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -15774,7 +15774,15 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}}}- const governed = (isComposer && !firstAfterClause?.isNegated)+ // A composer opened under an explicit publish prohibition ("Do not+ // publish anything; open <composer> to inspect it") is for reading,+ // not posting: the prohibition anywhere in the trusted context vetoes+ // the verb-free composer shortcut (an affirmative publish command still+ // governs through the other arms below).+ const hasPublishProhibition = clauses.some(clause => (+ clause.isNegated && SOCIAL_PUBLISH_VERBS.test(clause.maskedText || clause.text || '')+ ));+ const governed = (isComposer && !firstAfterClause?.isNegated && !hasPublishProhibition)|| publishGoverned|| (SOCIAL_PUBLISH_DESTINATION_LEAD.test(lastBeforeClause?.text || '')&& this._socialPublicationCommandIn(firstAfterClause?.text || ''));@@ -24421,7 +24429,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d&& ((SOCIAL_COORDINATING_DELIMITER.test(following.delim || '')&& anyPlatformPattern.test(following.maskedText || following.text || ''))|| startsNewPublication(following.maskedText || following.text || ''));- if (!followingStartsDestination) {+ // A sequential step ("Then let me know...") is a new+ // instruction either way, so its glue is dropped too.+ const followingStartsSequence = following+ && SOCIAL_SEQUENTIAL_DELIMITER.test(following.delim || '');+ if (!followingStartsDestination && !followingStartsSequence) {if (/^[.!?;:,、,。;:]$/.test(bodyDelim)) scoped += bodyDelim;else if (bodyDelim) scoped += ` ${bodyDelim}`;}@@ -24442,6 +24454,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (SOCIAL_COORDINATING_DELIMITER.test(bodyDelim)&& anyPlatformPattern.test(bodyMasked)) break;if (startsNewPublication(bodyMasked)) break;+ // A sequential step ("Then let me know when it is done")+ // starts a new instruction, not body prose.+ if (SOCIAL_SEQUENTIAL_DELIMITER.test(bodyDelim)) break;if (/^[.!?;:,、,。;:]$/.test(bodyDelim)) scoped += `${bodyDelim}${bodyClause.text}`;else scoped += ` ${bodyDelim}${bodyClause.text}`;}@@ -24708,8 +24723,21 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (extractedBody) {const bodyReq = details.items.find(r => r.field === 'body');if (bodyReq) {+ // An operational follow-up ("Then let me know when it is done")+ // is not post prose: replace an explicit placeholder, an exact+ // match, or a truncation the extraction identifiably continues+ // (the classified value ends mid-token and the extraction+ // carries that same token on). A value ending at a word+ // boundary is complete as stated and never grows.+ const normalizedExtracted = this._workflowMetadataValue(extractedBody);+ const normalizedClassified = this._workflowMetadataValue(bodyReq.value);+ const continuationIndex = normalizedExtracted.indexOf(normalizedClassified);+ const continuesMidWord = normalizedClassified.length > 0 && continuationIndex >= 0+ && /[\p{L}\p{N}_]$/u.test(normalizedClassified)+ && /^[\p{L}\p{N}_]/u.test(normalizedExtracted.slice(continuationIndex + normalizedClassified.length));if (bodyReq.value === '[from task]'- || extractedBody.includes(bodyReq.value)) {+ || normalizedExtracted === normalizedClassified+ || continuesMidWord) {bodyReq.value = this._workflowMetadataValue(extractedBody, 25000);}} else if (siteWorkflow?.job?.id === 'publish-post' || siteWorkflow?.job?.id === 'publish-content') {diff --git a/test/run.js b/test/run.jsindex 6449da750..d7cb8e47c 100644--- a/test/run.js+++ b/test/run.js@@ -91027,6 +91027,8 @@ test('social publication workflow follows the live X or Bluesky destination and'per-destination bodies should still discover both platforms'],['Post on X: I posted on Bluesky yesterday.', ['twitter'],'colon-scoped body prose adopted Bluesky as a destination'],+ ['Do not publish anything; open https://x.com/compose/post to inspect it, then submit findings in the form', [],+ 'a prohibited composer URL was adopted as a publish destination'],['Post on X: hello. Post on Bluesky: world', ['twitter', 'bluesky'],'a second colon command still discovers its destination'],['Post on X along with Bluesky', ['twitter', 'bluesky'],@@ -91195,6 +91197,8 @@ test('social destination rebinding refreshes platform-specific payload and uploaAgentClass.name + ': trailing attachment instruction contaminated the post body');assert.equal(agent._extractWorkflowTaskBody('Post on X: Hello. We uploaded our new release today.', '', 'twitter'), 'Hello. We uploaded our new release today.',AgentClass.name + ': prose mentioning an upload without media ended the post body');+ assert.equal(agent._extractWorkflowTaskBody('Post on X: Hello world. Then let me know when it is done', '', 'twitter'), 'Hello world',+ AgentClass.name + ': sequential follow-up instruction contaminated the post body');assert.equal(agent._extractWorkflowTaskBody('Post on X: hello; and on Bluesky: goodbye', '', 'twitter'), 'hello',AgentClass.name + ': a following destination body contaminated the X body');assert.equal(agent._extractWorkflowTaskBody('Post on X: hello; and on Bluesky: goodbye', '', 'bluesky'), 'goodbye',