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): preserve scoped publication clauses
Barack Sokullu998ab61a1c11
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 68dfa3dbf..904f99a7e 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -261,7 +261,7 @@ const SOCIAL_POST_DESTINATION_NEGATION = new RegExp('iu',);const SOCIAL_CONTRASTIVE_EXCLUSION = /(?<![\p{L}\p{N}_])(?:rather\s+than|instead\s+of)(?:\s+(?:post(?:ing)?|publish(?:ing)?|shar(?:e|ing)|tweet(?:ing)?|send(?:ing)?))?(?:\s+(?:on|onto|to|via|in|at))?\s*$/iu;-const SOCIAL_DESTINATION_EXCLUSION = /^\s*(?:exclude|excluding|avoid|avoiding|no)\s+(?:(?:post(?:ing)?|publish(?:ing)?|shar(?:e|ing)|tweet(?:ing)?|send(?:ing)?)\s+)?(?:(?:on|onto|to|via|in|at)\s+)?(?:the\s+)?(?:x|twitter|bluesky|bsky(?:\.app)?)(?![\p{L}\p{N}_.-])\s*$/iu;+const SOCIAL_DESTINATION_EXCLUSION = /^\s*(?:exclude|excluding|avoid|avoiding|skip|skipping|no)\s+(?:(?:post(?:ing)?|publish(?:ing)?|shar(?:e|ing)|tweet(?:ing)?|send(?:ing)?)\s+)?(?:(?:on|onto|to|via|in|at)\s+)?(?:the\s+)?(?:x|twitter|bluesky|bsky(?:\.app)?)(?![\p{L}\p{N}_.-])\s*$/iu;const socialPostNegationGovernsPublish = value => (SOCIAL_POST_NEGATION.test(String(value || '').trim())|| SOCIAL_POST_DESTINATION_NEGATION.test(String(value || ''))@@ -3474,6 +3474,7 @@ export class Agent extends LoopDetector {'giu',);const attachmentKindForAlternativeNoun = noun => {+ if (new RegExp(`^(?:${IMAGE_ATTACHMENT_FORMAT}|${VIDEO_ATTACHMENT_FORMAT})$`, 'iu').test(noun)) return '';if (RAW_GIF_NOUN_REGEX.test(noun)) return 'gif';if (RAW_IMAGE_NOUN_REGEX.test(noun)) return 'image';if (RAW_VIDEO_NOUN_REGEX.test(noun)) return 'video';@@ -17428,11 +17429,22 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d_socialPublicationClauses(text) {const raw = String(text || '');const masked = this._maskQuotedPayload(raw);- const parts = masked.split(SOCIAL_CLAUSE_DELIMITER);+ // URL punctuation is content, not clause structure. Hide only the+ // delimiter characters from the splitter and slice the original masked+ // text below, so platform discovery still receives intact URLs.+ const delimiterMasked = masked.replace(+ /https?:\/\/[^\s<>"'`\u3002\u3001\uff0c\uff1b\uff1a\uff01\uff1f\u2026\u2025]+/gi,+ (rawUrl) => {+ const url = this._workflowTrimUrlPunctuation(rawUrl);+ return url.replace(/[.!?;:,]/g, '\u0001') + rawUrl.slice(url.length);+ },+ );+ const parts = delimiterMasked.split(SOCIAL_CLAUSE_DELIMITER);const clauses = [];let offset = 0;for (let i = 0; i < parts.length; i += 2) {- const maskedClause = parts[i] || '';+ const clauseLength = (parts[i] || '').length;+ const maskedClause = masked.slice(offset, offset + clauseLength);const delim = i > 0 ? (parts[i - 1] || '').trim() : '';const rawClause = raw.slice(offset, offset + maskedClause.length);clauses.push({ text: rawClause, maskedText: maskedClause, delim });diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 550010eb6..d0a6b3598 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -195,7 +195,7 @@ const SOCIAL_POST_DESTINATION_NEGATION = new RegExp('iu',);const SOCIAL_CONTRASTIVE_EXCLUSION = /(?<![\p{L}\p{N}_])(?:rather\s+than|instead\s+of)(?:\s+(?:post(?:ing)?|publish(?:ing)?|shar(?:e|ing)|tweet(?:ing)?|send(?:ing)?))?(?:\s+(?:on|onto|to|via|in|at))?\s*$/iu;-const SOCIAL_DESTINATION_EXCLUSION = /^\s*(?:exclude|excluding|avoid|avoiding|no)\s+(?:(?:post(?:ing)?|publish(?:ing)?|shar(?:e|ing)|tweet(?:ing)?|send(?:ing)?)\s+)?(?:(?:on|onto|to|via|in|at)\s+)?(?:the\s+)?(?:x|twitter|bluesky|bsky(?:\.app)?)(?![\p{L}\p{N}_.-])\s*$/iu;+const SOCIAL_DESTINATION_EXCLUSION = /^\s*(?:exclude|excluding|avoid|avoiding|skip|skipping|no)\s+(?:(?:post(?:ing)?|publish(?:ing)?|shar(?:e|ing)|tweet(?:ing)?|send(?:ing)?)\s+)?(?:(?:on|onto|to|via|in|at)\s+)?(?:the\s+)?(?:x|twitter|bluesky|bsky(?:\.app)?)(?![\p{L}\p{N}_.-])\s*$/iu;const socialPostNegationGovernsPublish = value => (SOCIAL_POST_NEGATION.test(String(value || '').trim())|| SOCIAL_POST_DESTINATION_NEGATION.test(String(value || ''))@@ -3189,6 +3189,7 @@ export class Agent extends LoopDetector {'giu',);const attachmentKindForAlternativeNoun = noun => {+ if (new RegExp(`^(?:${IMAGE_ATTACHMENT_FORMAT}|${VIDEO_ATTACHMENT_FORMAT})$`, 'iu').test(noun)) return '';if (RAW_GIF_NOUN_REGEX.test(noun)) return 'gif';if (RAW_IMAGE_NOUN_REGEX.test(noun)) return 'image';if (RAW_VIDEO_NOUN_REGEX.test(noun)) return 'video';@@ -15227,11 +15228,22 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d_socialPublicationClauses(text) {const raw = String(text || '');const masked = this._maskQuotedPayload(raw);- const parts = masked.split(SOCIAL_CLAUSE_DELIMITER);+ // URL punctuation is content, not clause structure. Hide only the+ // delimiter characters from the splitter and slice the original masked+ // text below, so platform discovery still receives intact URLs.+ const delimiterMasked = masked.replace(+ /https?:\/\/[^\s<>"'`\u3002\u3001\uff0c\uff1b\uff1a\uff01\uff1f\u2026\u2025]+/gi,+ (rawUrl) => {+ const url = this._workflowTrimUrlPunctuation(rawUrl);+ return url.replace(/[.!?;:,]/g, '\u0001') + rawUrl.slice(url.length);+ },+ );+ const parts = delimiterMasked.split(SOCIAL_CLAUSE_DELIMITER);const clauses = [];let offset = 0;for (let i = 0; i < parts.length; i += 2) {- const maskedClause = parts[i] || '';+ const clauseLength = (parts[i] || '').length;+ const maskedClause = masked.slice(offset, offset + clauseLength);const delim = i > 0 ? (parts[i - 1] || '').trim() : '';const rawClause = raw.slice(offset, offset + maskedClause.length);clauses.push({ text: rawClause, maskedText: maskedClause, delim });diff --git a/test/run.js b/test/run.jsindex 20b2d459d..dd8bc8e2a 100644--- a/test/run.js+++ b/test/run.js@@ -90825,6 +90825,10 @@ test('social publication workflow follows the live X or Bluesky destination and'an avoiding clause adopted its forbidden X destination'],['Post on X, avoid Bluesky', ['twitter'],'an avoid clause adopted its forbidden Bluesky destination'],+ ['Post on Bluesky, skip X', ['bluesky'],+ 'a skip clause adopted its forbidden X destination'],+ ['Post on X, skipping Bluesky', ['twitter'],+ 'a skipping clause adopted its forbidden Bluesky destination'],['Post on Bluesky rather than posting on X', ['bluesky'],'rather-than clause adopted its expressly excluded X destination'],['Post on Bluesky rather than on X', ['bluesky'],@@ -92459,6 +92463,16 @@ test('extracting post body skips URL scheme colons', () => {'Announcing v2!',AgentClass.name + ': Bluesky URL scheme colon halted body extraction',);+ assert.equal(+ agent._extractWorkflowTaskBody('Post on X: https://example.com/path'),+ 'https://example.com/path',+ AgentClass.name + ': punctuation inside an unquoted URL truncated the post body',+ );+ assert.equal(+ agent._extractWorkflowTaskBody('Post on X: Visit https://example.com/path today'),+ 'Visit https://example.com/path today',+ AgentClass.name + ': an embedded unquoted URL truncated the surrounding post body',+ );}});@@ -92996,6 +93010,12 @@ test('upper-bound attachment qualifiers verify as maximum counts', () => {assert.equal(agent._workflowSocialPublishedAttachmentObserved({ value: 'one PNG or JPEG image' }, { attachments: [{ type: 'image', src: 'https://cdn.example/a.webp' }] }), false,AgentClass.name + ': WebP satisfied a PNG-or-JPEG format choice');+ 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');+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(+ { value: 'one image or one PNG image' }, { attachments: [{ type: 'image', src: 'https://cdn.example/a.jpg' }] }), true,+ AgentClass.name + ': the unrestricted image branch incorrectly required PNG');const pngAndJpegImages = agent._parseWorkflowAttachmentRequirement('one PNG image and one JPEG image');assert.equal(pngAndJpegImages.expectedImageCount, 2,AgentClass.name + ': conjunctive image-format counts were not summed');