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): scope bodies and count alternatives
Barack Sokullu3e5efc8e78cc
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 59d41b1c9..2e290c0a7 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -3227,14 +3227,24 @@ export class Agent extends LoopDetector {}const DISJUNCTION_REGEX = /(?:\b(?:or|oder|ou|o|oppure|или|либо|veya|ya\s+da)\b|[或或者]|(?:또는|혹은)|(?:または|それとも))/i;- const isAlternative = isGeneric && wantsImage && wantsVideo && DISJUNCTION_REGEX.test(text);+ const hasDisjunction = isGeneric && DISJUNCTION_REGEX.test(text);+ const requestedTypeCount = Number(wantsImage) + Number(wantsOrdinaryVideo) + Number(wantsGif);+ const alternativeCounts = hasDisjunction && requestedTypeCount <= 1+ ? [...countText.matchAll(new RegExp(`(?<![${SOCIAL_WORD_EDGE}])(${countPrefix})(?![${SOCIAL_WORD_EDGE}])`, 'giu'))]+ .filter(match => isExplicitCountWord(match[1]))+ .map(match => parseCountWord(match[1]))+ .filter((count, index, counts) => counts.indexOf(count) === index)+ : [];+ const isAlternative = hasDisjunction;let hasExplicitGenericCount = false;let expectedCount = 1;if (isGeneric) {const combinedVideoCount = expectedVideoCount + expectedGifCount;if (isAlternative) {- if (expectedImageCount > 0 && combinedVideoCount > 0) {+ if (alternativeCounts.length > 0) {+ expectedCount = Math.min(...alternativeCounts);+ } else if (expectedImageCount > 0 && combinedVideoCount > 0) {expectedCount = Math.min(expectedImageCount, combinedVideoCount);} else if (expectedImageCount > 0) {expectedCount = expectedImageCount;@@ -3301,6 +3311,7 @@ export class Agent extends LoopDetector {isVideoNegated,isGifNegated,isAlternative,+ alternativeCounts,isMinimumCount,isImageMinimum,isVideoMinimum,@@ -3387,9 +3398,12 @@ export class Agent extends LoopDetector {if (!want) return rawAttachments.length > 0;const parsed = this._parseWorkflowAttachmentRequirement(want);- if (parsed.wantsNone || parsed.expectedCount === 0 || parsed.isNegative) {+ if (parsed.wantsNone+ || (parsed.expectedCount === 0 && !parsed.alternativeCounts?.length)+ || parsed.isNegative) {return rawAttachments.length === 0;}+ if (!rawAttachments.length && parsed.alternativeCounts?.includes(0)) return true;// An upper bound does not imply that one attachment is required. Empty// media is valid only when every conjunctive positive constraint permits// zero; for alternatives, one maximum-qualified branch is sufficient.@@ -3443,9 +3457,12 @@ export class Agent extends LoopDetector {const gifCount = rawAttachments.filter(isGifAttachment).length;const ordinaryVideoCount = rawAttachments.filter(att => isVideoAttachment(att) && !isGifAttachment(att)).length;if (parsed.wantsGif) {- const requiredGifCount = parsed.isGifMaximum ? 0 : (parsed.expectedGifCount > 0 ? parsed.expectedGifCount : 1);+ const requiredGifCount = parsed.alternativeCounts?.length+ ? Math.min(...parsed.alternativeCounts)+ : (parsed.isGifMaximum ? 0 : (parsed.expectedGifCount > 0 ? parsed.expectedGifCount : 1));if (gifCount < requiredGifCount) return false;- if (parsed.hasExplicitGifCount && !parsed.isGifMinimum && !parsed.isGifMaximum && gifCount !== parsed.expectedGifCount) return false;+ if (parsed.hasExplicitGifCount && !parsed.alternativeCounts?.length+ && !parsed.isGifMinimum && !parsed.isGifMaximum && gifCount !== parsed.expectedGifCount) return false;if (parsed.hasExplicitGifCount && parsed.isGifMaximum && gifCount > parsed.expectedGifCount) return false;}if (parsed.wantsGif && parsed.wantsOrdinaryVideo) {@@ -3549,7 +3566,11 @@ export class Agent extends LoopDetector {if (videoCount > 0) return false;const hasExactImageCount = !parsed.isImageMinimum && !parsed.isImageMaximum&& ((parsed.hasExplicitImageCount && !parsed.isImageNegated) || parsed.hasExplicitGenericCount);- if (hasExactImageCount) {+ if (parsed.alternativeCounts?.length) {+ if (!parsed.alternativeCounts.includes(imageCount) || rawAttachments.length !== imageCount) {+ return false;+ }+ } else if (hasExactImageCount) {if (imageCount !== parsed.expectedCount || rawAttachments.length !== parsed.expectedCount) {return false;}@@ -3573,7 +3594,11 @@ export class Agent extends LoopDetector {const hasExactVideoCount = (parsed.hasExplicitVideoCount && !parsed.isVideoNegated && !parsed.isVideoMinimum && !parsed.isVideoMaximum)|| (parsed.hasExplicitGifCount && !parsed.isGifNegated && !parsed.isGifMinimum && !parsed.isGifMaximum)|| (parsed.hasExplicitGenericCount && !parsed.isMaximumCount);- if (hasExactVideoCount) {+ if (parsed.alternativeCounts?.length) {+ if (!parsed.alternativeCounts.includes(videoCount) || rawAttachments.length !== videoCount) {+ return false;+ }+ } else if (hasExactVideoCount) {if (videoCount !== parsed.expectedCount || rawAttachments.length !== parsed.expectedCount) {return false;}@@ -3587,7 +3612,11 @@ export class Agent extends LoopDetector {}matchingAttachments = rawAttachments.filter(isVideoAttachment);} else {- if (parsed.hasExplicitCardinality && !parsed.isMinimumCount && !parsed.isMaximumCount) {+ if (parsed.alternativeCounts?.length) {+ if (!parsed.alternativeCounts.includes(rawAttachments.length)) {+ return false;+ }+ } else if (parsed.hasExplicitCardinality && !parsed.isMinimumCount && !parsed.isMaximumCount) {if (rawAttachments.length !== parsed.expectedCount) {return false;}@@ -25553,10 +25582,48 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dreturn '';}- _extractWorkflowTaskBody(taskText, approvedPlan) {- const candidates = [taskText, approvedPlan]+ _extractWorkflowTaskBody(taskText, approvedPlan, adapterName = '') {+ const rawCandidates = [taskText, approvedPlan].map(t => String(t || '').trim()).filter(Boolean);+ const scopedCandidates = [];+ let sawNamedSocialPlatform = false;+ if (adapterName === 'twitter' || adapterName === 'bluesky') {+ const platformPattern = adapterName === 'twitter'+ ? /(?:https?:\/\/(?:www\.)?(?:x\.com|twitter\.com)(?:[/?#]|$)|(?<![\p{L}\p{N}_])(?:x|twitter)(?![\p{L}\p{N}_]))/iu+ : /(?:https?:\/\/(?:www\.)?bsky\.app(?:[/?#]|$)|(?<![\p{L}\p{N}_])(?:bluesky|bsky\.app)(?![\p{L}\p{N}_]))/iu;+ const anyPlatformPattern = /(?:https?:\/\/(?:www\.)?(?:x\.com|twitter\.com|bsky\.app)(?:[/?#]|$)|(?<![\p{L}\p{N}_])(?:x|twitter|bluesky|bsky\.app)(?![\p{L}\p{N}_]))/iu;+ for (const rawCandidate of rawCandidates) {+ const clauses = this._socialPublicationClauses(rawCandidate);+ let carriedPublishVerb = 'post';+ for (let index = 0; index < clauses.length; index++) {+ const clause = clauses[index];+ const masked = clause.maskedText || clause.text || '';+ const publish = masked.match(SOCIAL_PUBLISH_VERBS);+ if (publish?.[0]) carriedPublishVerb = publish[0];+ if (anyPlatformPattern.test(masked)) sawNamedSocialPlatform = true;+ if (!platformPattern.test(masked)) continue;+ let scoped = publish ? clause.text : `${carriedPublishVerb} ${clause.text}`;+ for (let nextIndex = index + 1; nextIndex < clauses.length; nextIndex++) {+ const next = clauses[nextIndex];+ if ((next.delim || '').trim() === ':') {+ scoped += `:${next.text}`;+ break;+ }+ if (SOCIAL_COORDINATING_DELIMITER.test(next.delim || '')+ && anyPlatformPattern.test(next.maskedText || next.text || '')) {+ scoped += ` ${next.delim} ${next.text}`;+ continue;+ }+ break;+ }+ scopedCandidates.push(scoped);+ }+ }+ }+ const candidates = scopedCandidates.length > 0+ ? scopedCandidates+ : (sawNamedSocialPlatform ? [] : rawCandidates);let bestBody = '';const publishVerbPattern = `(?:${SOCIAL_PUBLISH_VERBS.source}|message|update)`;const quotedPattern = new RegExp(`${publishVerbPattern}[\\s\\S]*?(?:“([\\s\\S]+?)”|「([\\s\\S]+?)」|『([\\s\\S]+?)』|«([\\s\\S]+?)»|"([\\s\\S]+?)")`, 'iu');@@ -25779,7 +25846,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst details = this._normalizeWorkflowMetadataRequirementsDetails(obj?.workflowFields ?? obj?.workflow_fields,);- const extractedBody = this._extractWorkflowTaskBody(taskText, approvedPlanText);+ const extractedBody = this._extractWorkflowTaskBody(taskText, approvedPlanText, siteWorkflow?.adapterName);if (extractedBody) {const bodyReq = details.items.find(r => r.field === 'body');if (bodyReq) {@@ -25819,7 +25886,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (this._workflowJobStoresMetadataRequirements(siteWorkflow)) {const guard = this._planExecutionGuards.get(tabId);if (guard && guard.workflowMetadataRequirementsResolved !== true) {- const extractedBody = this._extractWorkflowTaskBody(taskText, approvedPlanText);+ const extractedBody = this._extractWorkflowTaskBody(taskText, approvedPlanText, siteWorkflow?.adapterName);if (extractedBody) {guard.workflowMetadataRequirements = [{field: 'body',diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 2d2a560bb..60468eb09 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -2942,14 +2942,24 @@ export class Agent extends LoopDetector {}const DISJUNCTION_REGEX = /(?:\b(?:or|oder|ou|o|oppure|или|либо|veya|ya\s+da)\b|[或或者]|(?:또는|혹은)|(?:または|それとも))/i;- const isAlternative = isGeneric && wantsImage && wantsVideo && DISJUNCTION_REGEX.test(text);+ const hasDisjunction = isGeneric && DISJUNCTION_REGEX.test(text);+ const requestedTypeCount = Number(wantsImage) + Number(wantsOrdinaryVideo) + Number(wantsGif);+ const alternativeCounts = hasDisjunction && requestedTypeCount <= 1+ ? [...countText.matchAll(new RegExp(`(?<![${SOCIAL_WORD_EDGE}])(${countPrefix})(?![${SOCIAL_WORD_EDGE}])`, 'giu'))]+ .filter(match => isExplicitCountWord(match[1]))+ .map(match => parseCountWord(match[1]))+ .filter((count, index, counts) => counts.indexOf(count) === index)+ : [];+ const isAlternative = hasDisjunction;let hasExplicitGenericCount = false;let expectedCount = 1;if (isGeneric) {const combinedVideoCount = expectedVideoCount + expectedGifCount;if (isAlternative) {- if (expectedImageCount > 0 && combinedVideoCount > 0) {+ if (alternativeCounts.length > 0) {+ expectedCount = Math.min(...alternativeCounts);+ } else if (expectedImageCount > 0 && combinedVideoCount > 0) {expectedCount = Math.min(expectedImageCount, combinedVideoCount);} else if (expectedImageCount > 0) {expectedCount = expectedImageCount;@@ -3016,6 +3026,7 @@ export class Agent extends LoopDetector {isVideoNegated,isGifNegated,isAlternative,+ alternativeCounts,isMinimumCount,isImageMinimum,isVideoMinimum,@@ -3102,9 +3113,12 @@ export class Agent extends LoopDetector {if (!want) return rawAttachments.length > 0;const parsed = this._parseWorkflowAttachmentRequirement(want);- if (parsed.wantsNone || parsed.expectedCount === 0 || parsed.isNegative) {+ if (parsed.wantsNone+ || (parsed.expectedCount === 0 && !parsed.alternativeCounts?.length)+ || parsed.isNegative) {return rawAttachments.length === 0;}+ if (!rawAttachments.length && parsed.alternativeCounts?.includes(0)) return true;// An upper bound does not imply that one attachment is required. Empty// media is valid only when every conjunctive positive constraint permits// zero; for alternatives, one maximum-qualified branch is sufficient.@@ -3158,9 +3172,12 @@ export class Agent extends LoopDetector {const gifCount = rawAttachments.filter(isGifAttachment).length;const ordinaryVideoCount = rawAttachments.filter(att => isVideoAttachment(att) && !isGifAttachment(att)).length;if (parsed.wantsGif) {- const requiredGifCount = parsed.isGifMaximum ? 0 : (parsed.expectedGifCount > 0 ? parsed.expectedGifCount : 1);+ const requiredGifCount = parsed.alternativeCounts?.length+ ? Math.min(...parsed.alternativeCounts)+ : (parsed.isGifMaximum ? 0 : (parsed.expectedGifCount > 0 ? parsed.expectedGifCount : 1));if (gifCount < requiredGifCount) return false;- if (parsed.hasExplicitGifCount && !parsed.isGifMinimum && !parsed.isGifMaximum && gifCount !== parsed.expectedGifCount) return false;+ if (parsed.hasExplicitGifCount && !parsed.alternativeCounts?.length+ && !parsed.isGifMinimum && !parsed.isGifMaximum && gifCount !== parsed.expectedGifCount) return false;if (parsed.hasExplicitGifCount && parsed.isGifMaximum && gifCount > parsed.expectedGifCount) return false;}if (parsed.wantsGif && parsed.wantsOrdinaryVideo) {@@ -3264,7 +3281,11 @@ export class Agent extends LoopDetector {if (videoCount > 0) return false;const hasExactImageCount = !parsed.isImageMinimum && !parsed.isImageMaximum&& ((parsed.hasExplicitImageCount && !parsed.isImageNegated) || parsed.hasExplicitGenericCount);- if (hasExactImageCount) {+ if (parsed.alternativeCounts?.length) {+ if (!parsed.alternativeCounts.includes(imageCount) || rawAttachments.length !== imageCount) {+ return false;+ }+ } else if (hasExactImageCount) {if (imageCount !== parsed.expectedCount || rawAttachments.length !== parsed.expectedCount) {return false;}@@ -3288,7 +3309,11 @@ export class Agent extends LoopDetector {const hasExactVideoCount = (parsed.hasExplicitVideoCount && !parsed.isVideoNegated && !parsed.isVideoMinimum && !parsed.isVideoMaximum)|| (parsed.hasExplicitGifCount && !parsed.isGifNegated && !parsed.isGifMinimum && !parsed.isGifMaximum)|| (parsed.hasExplicitGenericCount && !parsed.isMaximumCount);- if (hasExactVideoCount) {+ if (parsed.alternativeCounts?.length) {+ if (!parsed.alternativeCounts.includes(videoCount) || rawAttachments.length !== videoCount) {+ return false;+ }+ } else if (hasExactVideoCount) {if (videoCount !== parsed.expectedCount || rawAttachments.length !== parsed.expectedCount) {return false;}@@ -3302,7 +3327,11 @@ export class Agent extends LoopDetector {}matchingAttachments = rawAttachments.filter(isVideoAttachment);} else {- if (parsed.hasExplicitCardinality && !parsed.isMinimumCount && !parsed.isMaximumCount) {+ if (parsed.alternativeCounts?.length) {+ if (!parsed.alternativeCounts.includes(rawAttachments.length)) {+ return false;+ }+ } else if (parsed.hasExplicitCardinality && !parsed.isMinimumCount && !parsed.isMaximumCount) {if (rawAttachments.length !== parsed.expectedCount) {return false;}@@ -23160,10 +23189,48 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dreturn '';}- _extractWorkflowTaskBody(taskText, approvedPlan) {- const candidates = [taskText, approvedPlan]+ _extractWorkflowTaskBody(taskText, approvedPlan, adapterName = '') {+ const rawCandidates = [taskText, approvedPlan].map(t => String(t || '').trim()).filter(Boolean);+ const scopedCandidates = [];+ let sawNamedSocialPlatform = false;+ if (adapterName === 'twitter' || adapterName === 'bluesky') {+ const platformPattern = adapterName === 'twitter'+ ? /(?:https?:\/\/(?:www\.)?(?:x\.com|twitter\.com)(?:[/?#]|$)|(?<![\p{L}\p{N}_])(?:x|twitter)(?![\p{L}\p{N}_]))/iu+ : /(?:https?:\/\/(?:www\.)?bsky\.app(?:[/?#]|$)|(?<![\p{L}\p{N}_])(?:bluesky|bsky\.app)(?![\p{L}\p{N}_]))/iu;+ const anyPlatformPattern = /(?:https?:\/\/(?:www\.)?(?:x\.com|twitter\.com|bsky\.app)(?:[/?#]|$)|(?<![\p{L}\p{N}_])(?:x|twitter|bluesky|bsky\.app)(?![\p{L}\p{N}_]))/iu;+ for (const rawCandidate of rawCandidates) {+ const clauses = this._socialPublicationClauses(rawCandidate);+ let carriedPublishVerb = 'post';+ for (let index = 0; index < clauses.length; index++) {+ const clause = clauses[index];+ const masked = clause.maskedText || clause.text || '';+ const publish = masked.match(SOCIAL_PUBLISH_VERBS);+ if (publish?.[0]) carriedPublishVerb = publish[0];+ if (anyPlatformPattern.test(masked)) sawNamedSocialPlatform = true;+ if (!platformPattern.test(masked)) continue;+ let scoped = publish ? clause.text : `${carriedPublishVerb} ${clause.text}`;+ for (let nextIndex = index + 1; nextIndex < clauses.length; nextIndex++) {+ const next = clauses[nextIndex];+ if ((next.delim || '').trim() === ':') {+ scoped += `:${next.text}`;+ break;+ }+ if (SOCIAL_COORDINATING_DELIMITER.test(next.delim || '')+ && anyPlatformPattern.test(next.maskedText || next.text || '')) {+ scoped += ` ${next.delim} ${next.text}`;+ continue;+ }+ break;+ }+ scopedCandidates.push(scoped);+ }+ }+ }+ const candidates = scopedCandidates.length > 0+ ? scopedCandidates+ : (sawNamedSocialPlatform ? [] : rawCandidates);let bestBody = '';const publishVerbPattern = `(?:${SOCIAL_PUBLISH_VERBS.source}|message|update)`;const quotedPattern = new RegExp(`${publishVerbPattern}[\\s\\S]*?(?:“([\\s\\S]+?)”|「([\\s\\S]+?)」|『([\\s\\S]+?)』|«([\\s\\S]+?)»|"([\\s\\S]+?)")`, 'iu');@@ -23386,7 +23453,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst details = this._normalizeWorkflowMetadataRequirementsDetails(obj?.workflowFields ?? obj?.workflow_fields,);- const extractedBody = this._extractWorkflowTaskBody(taskText, approvedPlanText);+ const extractedBody = this._extractWorkflowTaskBody(taskText, approvedPlanText, siteWorkflow?.adapterName);if (extractedBody) {const bodyReq = details.items.find(r => r.field === 'body');if (bodyReq) {@@ -23426,7 +23493,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (this._workflowJobStoresMetadataRequirements(siteWorkflow)) {const guard = this._planExecutionGuards.get(tabId);if (guard && guard.workflowMetadataRequirementsResolved !== true) {- const extractedBody = this._extractWorkflowTaskBody(taskText, approvedPlanText);+ const extractedBody = this._extractWorkflowTaskBody(taskText, approvedPlanText, siteWorkflow?.adapterName);if (extractedBody) {guard.workflowMetadataRequirements = [{field: 'body',diff --git a/test/run.js b/test/run.jsindex be778764d..07e9c4ee0 100644--- a/test/run.js+++ b/test/run.js@@ -91002,7 +91002,7 @@ test('social destination rebinding refreshes platform-specific payload and uploaagent.useSiteAdapters = true;agent._persist = () => {};const tabId = 9040 + index;- const taskText = 'Post "A much longer announcement" on X and "B" on Bluesky.';+ const taskText = 'Post "Launch now" on X and "Launch" on Bluesky.';agent.conversations.set(tabId, [{ role: 'system', content: 'system' },{ role: 'user', content: taskText },@@ -91018,7 +91018,7 @@ test('social destination rebinding refreshes platform-specific payload and uploasiteWorkflow: twitterWorkflow,siteWorkflowUrl: 'https://x.com/compose/post',});- guard.workflowMetadataRequirements = [{ field: 'body', value: 'A much longer announcement' }];+ guard.workflowMetadataRequirements = [{ field: 'body', value: 'Launch now' }];guard.workflowMetadataRequirementsResolved = true;guard.workflowSocialUploadEvidence = [{ name: 'x-card.png', attachmentState: 'input_attached', actionSequence: 3 }];agent._currentUrl = async () => 'https://bsky.app/';@@ -91033,7 +91033,7 @@ test('social destination rebinding refreshes platform-specific payload and uploaallowedActions: [],forbiddenActions: [],targets: [],- workflowFields: [{ field: 'body', value: 'B' }],+ workflowFields: [{ field: 'body', value: 'Launch' }],confidence: 0.99,pageScopePolicy: 'page',}),@@ -91041,8 +91041,12 @@ test('social destination rebinding refreshes platform-specific payload and uploa};assert.equal(await agent._adoptLiveSocialPublishWorkflow(tabId, { chat: async () => ({ content: '{}' }) }), true);assert.equal(classifiedAdapter, 'bluesky', AgentClass.name + ': rebind classified the stale platform');- assert.deepEqual(guard.workflowMetadataRequirements, [{ field: 'body', value: 'B' }],+ assert.deepEqual(guard.workflowMetadataRequirements, [{ field: 'body', value: 'Launch' }],AgentClass.name + ': longer X body overwrote the Bluesky-specific payload');+ assert.equal(agent._extractWorkflowTaskBody(taskText, '', 'twitter'), 'Launch now',+ AgentClass.name + ': X-scoped body recovery selected the Bluesky payload');+ assert.equal(agent._extractWorkflowTaskBody(taskText, '', 'bluesky'), 'Launch',+ AgentClass.name + ': Bluesky-scoped body recovery selected the X payload');assert.equal(guard.workflowMetadataRequirementsResolved, true);assert.deepEqual(guard.workflowSocialUploadEvidence, [],AgentClass.name + ': X upload provenance leaked into the Bluesky binding');@@ -93644,6 +93648,30 @@ test('attachment verification matches specific attachment names without substrinAgentClass.name + ': simultaneous image and video should reject "one image or one video"');+ for (const [sameTypeRequirement, attachment] of [+ ['one or two images', index => ({ type: 'image', src: `https://example.test/${index}.png` })],+ ['one image or two images', index => ({ type: 'image', src: `https://example.test/${index}.png` })],+ ['one or two videos', index => ({ type: 'video', src: `https://example.test/${index}.mp4` })],+ ['one or two GIFs', index => ({ type: 'animated_gif', src: `https://example.test/${index}.gif` })],+ ['one or two attachments', index => ({ type: 'image', src: `https://example.test/${index}.png` })],+ ]) {+ const parsedSameType = agent._parseWorkflowAttachmentRequirement(sameTypeRequirement);+ assert.equal(parsedSameType.isAlternative, true,+ AgentClass.name + `: same-type disjunction was not retained for "${sameTypeRequirement}"`);+ assert.deepEqual(parsedSameType.alternativeCounts, [1, 2],+ AgentClass.name + `: alternative counts were lost for "${sameTypeRequirement}"`);+ for (const count of [1, 2]) {+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(+ { value: sameTypeRequirement },+ { attachments: Array.from({ length: count }, (_, index) => attachment(index)) },+ ), true, AgentClass.name + `: ${count} attachments should satisfy "${sameTypeRequirement}"`);+ }+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(+ { value: sameTypeRequirement },+ { attachments: Array.from({ length: 3 }, (_, index) => attachment(index)) },+ ), false, AgentClass.name + `: three attachments should reject "${sameTypeRequirement}"`);+ }+// Media-only generic phrase checkconst parsedOnly = agent._parseWorkflowAttachmentRequirement({ value: 'images only' });assert.equal(parsedOnly.isGeneric, true, AgentClass.name + ': "images only" should be parsed as generic');