Skip to content

Open-source AI browser agent for Chrome and Firefox (monorepo) 🧠

fix(social-publish): preserve polarity and bounded media

Barack Sokullub0b7b3631b36
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 41cffd26a..318ab5fcc 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -300,7 +300,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', 'or', 'plus', 'also', 'as', 'well',
+ 'and', 'or', 'plus', 'also', 'as', 'well', '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', 'без', 'нет',
@@ -3129,11 +3129,31 @@ export class Agent extends LoopDetector {
return explicitWords.has(s);
};
+ // A bounded range carries two independent limits. Keep the noun in the
+ // match so the bounds can be applied to the requested media subtype rather
+ // than accidentally constraining every attachment in a mixed requirement.
+ const rangeCountToken = '(?:\\d+|zero|one|two|three|four|five|six|seven|eight|nine|ten|a|an)';
+ const boundedCountRangeMatch = text.match(new RegExp(
+ `\\b(?:between\\s+(${rangeCountToken})\\s+and\\s+(${rangeCountToken})|from\\s+(${rangeCountToken})\\s+to\\s+(${rangeCountToken}))`
+ + '\\s+(images?|photos?|pictures?|pics?|videos?|clips?|recordings?|gifs?|attachments?|files?|media|uploads?|items?|assets?)\\b',
+ 'iu',
+ ));
+ const rangeMinimumCount = parseCountWord(boundedCountRangeMatch?.[1] || boundedCountRangeMatch?.[3]);
+ const rangeMaximumCount = parseCountWord(boundedCountRangeMatch?.[2] || boundedCountRangeMatch?.[4]);
+ const hasBoundedCountRange = Boolean(
+ boundedCountRangeMatch && rangeMaximumCount >= rangeMinimumCount,
+ );
+ const boundedRangeNoun = hasBoundedCountRange ? boundedCountRangeMatch[5] : '';
+ const boundedRangeKind = RAW_GIF_NOUN_REGEX.test(boundedRangeNoun) ? 'gif'
+ : RAW_IMAGE_NOUN_REGEX.test(boundedRangeNoun) ? 'image'
+ : RAW_VIDEO_NOUN_REGEX.test(boundedRangeNoun) ? 'video'
+ : 'generic';
+
// A minimum- or maximum-count qualifier says how many attachments are
// wanted, not which file, so both the generic-media test and the count
// scan read the requirement with the qualifier removed.
- const hasMinCountQualifier = MIN_ATTACHMENT_COUNT_REGEX.test(text);
- const hasMaxCountQualifier = MAX_ATTACHMENT_COUNT_REGEX.test(text);
+ const hasMinCountQualifier = MIN_ATTACHMENT_COUNT_REGEX.test(text) || hasBoundedCountRange;
+ const hasMaxCountQualifier = MAX_ATTACHMENT_COUNT_REGEX.test(text) || hasBoundedCountRange;
const countText = (hasMinCountQualifier || hasMaxCountQualifier)
? text.replace(MIN_ATTACHMENT_COUNT_STRIP_REGEX, ' ').replace(MAX_ATTACHMENT_COUNT_STRIP_REGEX, ' ').replace(/\s+/g, ' ').trim()
: text;
@@ -3164,6 +3184,12 @@ export class Agent extends LoopDetector {
if (!segmentImage && !segmentVideo && !segmentGif) minScopedGeneric = true;
}
}
+ if (hasBoundedCountRange) {
+ if (boundedRangeKind === 'image') minScopedImage = true;
+ else if (boundedRangeKind === 'video') minScopedVideo = true;
+ else if (boundedRangeKind === 'gif') minScopedGif = true;
+ else minScopedGeneric = true;
+ }
const isMinimumCount = isGeneric && hasMinCountQualifier;
const isImageMinimum = isGeneric && (minScopedImage || minScopedGeneric);
const isVideoMinimum = isGeneric && (minScopedVideo || minScopedGeneric);
@@ -3186,6 +3212,12 @@ export class Agent extends LoopDetector {
if (!segmentImage && !segmentVideo && !segmentGif) maxScopedGeneric = true;
}
}
+ if (hasBoundedCountRange) {
+ if (boundedRangeKind === 'image') maxScopedImage = true;
+ else if (boundedRangeKind === 'video') maxScopedVideo = true;
+ else if (boundedRangeKind === 'gif') maxScopedGif = true;
+ else maxScopedGeneric = true;
+ }
const isMaximumCount = isGeneric && hasMaxCountQualifier;
const isImageMaximum = isGeneric && (maxScopedImage || maxScopedGeneric);
const isVideoMaximum = isGeneric && (maxScopedVideo || maxScopedGeneric);
@@ -3294,6 +3326,10 @@ export class Agent extends LoopDetector {
if (!isAlternative && wantsImage && wantsVideo && expectedCount < 2) {
expectedCount = 2;
}
+ if (hasBoundedCountRange) {
+ expectedCount = rangeMaximumCount;
+ if (boundedRangeKind === 'generic') hasExplicitGenericCount = true;
+ }
} else {
const specificTargets = this._parseSpecificAttachmentTargets(rawVal);
// Word joiners need surrounding whitespace so a filename such as
@@ -3304,10 +3340,10 @@ export class Agent extends LoopDetector {
.map(group => this._parseSpecificAttachmentTargets(group))
.filter(group => group.length > 0)
: [];
- // In "logo.png and either chart.png or graph.png", `either` scopes the
- // choice while everything before it remains a requirement in both
- // branches. Distribute that shared prefix instead of parsing ordinary
- // AND-before-OR precedence and accidentally accepting graph.png alone.
+ // In "logo.png and either chart.png or graph.png, and caption.png",
+ // `either` scopes the choice while the surrounding conjuncts remain
+ // requirements in both branches. Distribute both sides instead of
+ // accepting a branch that omits a shared file.
if (specificTargetAlternatives.length > 1) {
const eitherIndex = specificTargetAlternatives[0]
.findIndex(target => /^(?:either|one\s+of)\s+/iu.test(target));
@@ -3315,8 +3351,28 @@ export class Agent extends LoopDetector {
const sharedPrefix = specificTargetAlternatives[0].slice(0, eitherIndex);
const firstChoice = specificTargetAlternatives[0].slice(eitherIndex);
firstChoice[0] = firstChoice[0].replace(/^(?:either|one\s+of)\s+/iu, '');
- specificTargetAlternatives = [firstChoice, ...specificTargetAlternatives.slice(1)]
- .map(group => [...sharedPrefix, ...group]);
+ const choiceGroups = [firstChoice, ...specificTargetAlternatives.slice(1)];
+ const maskedTargets = this._maskQuotedPayload(String(rawVal || ''));
+ const trailingConjunct = /[,;]\s*(?:and|plus|also|as\s+well\s+as)\s+/giu;
+ let trailingBoundary = null;
+ for (const match of maskedTargets.matchAll(trailingConjunct)) trailingBoundary = match;
+ const sharedSuffix = trailingBoundary
+ ? this._parseSpecificAttachmentTargets(
+ String(rawVal || '').slice((trailingBoundary.index || 0) + trailingBoundary[0].length),
+ )
+ : [];
+ if (sharedSuffix.length > 0) {
+ const lastGroup = choiceGroups[choiceGroups.length - 1];
+ const suffixStart = lastGroup.length - sharedSuffix.length;
+ const suffixIsTail = suffixStart >= 1 && sharedSuffix.every(
+ (target, index) => lastGroup[suffixStart + index] === target,
+ );
+ if (suffixIsTail) choiceGroups[choiceGroups.length - 1] = lastGroup.slice(0, suffixStart);
+ else sharedSuffix.length = 0;
+ }
+ specificTargetAlternatives = choiceGroups.map(group => (
+ [...new Set([...sharedPrefix, ...group, ...sharedSuffix])]
+ ));
}
}
if (specificTargetAlternatives.length > 1) {
@@ -3362,6 +3418,10 @@ export class Agent extends LoopDetector {
isImageMaximum,
isVideoMaximum,
isGifMaximum,
+ hasBoundedCountRange,
+ minimumCount: hasBoundedCountRange ? rangeMinimumCount : 0,
+ maximumCount: hasBoundedCountRange ? rangeMaximumCount : 0,
+ boundedRangeKind,
wantsImage,
wantsVideo,
wantsOrdinaryVideo,
@@ -3450,7 +3510,8 @@ export class Agent extends LoopDetector {
// 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.
- const allowsNoAttachments = parsed.isGeneric && (
+ const allowsNoAttachments = parsed.isGeneric
+ && !(parsed.hasBoundedCountRange && parsed.minimumCount > 0) && (
parsed.isAlternative
? (parsed.isMaximumCount
|| (parsed.wantsImage && parsed.isImageMaximum)
@@ -3533,6 +3594,13 @@ export class Agent extends LoopDetector {
const videoCount = rawAttachments.filter(isVideoAttachment).length;
const gifCount = rawAttachments.filter(isGifAttachment).length;
const ordinaryVideoCount = rawAttachments.filter(att => isVideoAttachment(att) && !isGifAttachment(att)).length;
+ if (parsed.hasBoundedCountRange) {
+ const boundedCount = parsed.boundedRangeKind === 'image' ? imageCount
+ : parsed.boundedRangeKind === 'video' ? ordinaryVideoCount
+ : parsed.boundedRangeKind === 'gif' ? gifCount
+ : rawAttachments.length;
+ if (boundedCount < parsed.minimumCount || boundedCount > parsed.maximumCount) return false;
+ }
if (parsed.wantsGif) {
const requiredGifCount = parsed.alternativeCounts?.length
? Math.min(...parsed.alternativeCounts)
@@ -16883,6 +16951,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (!isCoordinated) carriedNegation = false;
const publish = c.maskedText.match(SOCIAL_PUBLISH_VERBS);
+ const hasExplicitAffirmative = Boolean(
+ publish && /(?<![\p{L}\p{N}_])do\s*$/iu.test(c.maskedText.slice(0, publish.index)),
+ );
let hasExplicitNeg = false;
if (publish) {
const beforeVerb = c.maskedText.slice(0, publish.index);
@@ -16895,10 +16966,14 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (hasExplicitNeg) {
c.isNegated = true;
carriedNegation = true;
- } else if (carriedNegation) {
+ } else if (carriedNegation && !hasExplicitAffirmative) {
c.isNegated = true;
} else {
c.isNegated = false;
+ // An explicit affirmative publish clause ("and do post...") starts a
+ // new polarity scope. Elliptical coordinated destinations still
+ // inherit the preceding negation.
+ if (hasExplicitAffirmative) carriedNegation = false;
}
}
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 52f7e750a..d0b3b6fa1 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -234,7 +234,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', 'or', 'plus', 'also', 'as', 'well',
+ 'and', 'or', 'plus', 'also', 'as', 'well', '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', 'без', 'нет',
@@ -2844,11 +2844,31 @@ export class Agent extends LoopDetector {
return explicitWords.has(s);
};
+ // A bounded range carries two independent limits. Keep the noun in the
+ // match so the bounds can be applied to the requested media subtype rather
+ // than accidentally constraining every attachment in a mixed requirement.
+ const rangeCountToken = '(?:\\d+|zero|one|two|three|four|five|six|seven|eight|nine|ten|a|an)';
+ const boundedCountRangeMatch = text.match(new RegExp(
+ `\\b(?:between\\s+(${rangeCountToken})\\s+and\\s+(${rangeCountToken})|from\\s+(${rangeCountToken})\\s+to\\s+(${rangeCountToken}))`
+ + '\\s+(images?|photos?|pictures?|pics?|videos?|clips?|recordings?|gifs?|attachments?|files?|media|uploads?|items?|assets?)\\b',
+ 'iu',
+ ));
+ const rangeMinimumCount = parseCountWord(boundedCountRangeMatch?.[1] || boundedCountRangeMatch?.[3]);
+ const rangeMaximumCount = parseCountWord(boundedCountRangeMatch?.[2] || boundedCountRangeMatch?.[4]);
+ const hasBoundedCountRange = Boolean(
+ boundedCountRangeMatch && rangeMaximumCount >= rangeMinimumCount,
+ );
+ const boundedRangeNoun = hasBoundedCountRange ? boundedCountRangeMatch[5] : '';
+ const boundedRangeKind = RAW_GIF_NOUN_REGEX.test(boundedRangeNoun) ? 'gif'
+ : RAW_IMAGE_NOUN_REGEX.test(boundedRangeNoun) ? 'image'
+ : RAW_VIDEO_NOUN_REGEX.test(boundedRangeNoun) ? 'video'
+ : 'generic';
+
// A minimum- or maximum-count qualifier says how many attachments are
// wanted, not which file, so both the generic-media test and the count
// scan read the requirement with the qualifier removed.
- const hasMinCountQualifier = MIN_ATTACHMENT_COUNT_REGEX.test(text);
- const hasMaxCountQualifier = MAX_ATTACHMENT_COUNT_REGEX.test(text);
+ const hasMinCountQualifier = MIN_ATTACHMENT_COUNT_REGEX.test(text) || hasBoundedCountRange;
+ const hasMaxCountQualifier = MAX_ATTACHMENT_COUNT_REGEX.test(text) || hasBoundedCountRange;
const countText = (hasMinCountQualifier || hasMaxCountQualifier)
? text.replace(MIN_ATTACHMENT_COUNT_STRIP_REGEX, ' ').replace(MAX_ATTACHMENT_COUNT_STRIP_REGEX, ' ').replace(/\s+/g, ' ').trim()
: text;
@@ -2879,6 +2899,12 @@ export class Agent extends LoopDetector {
if (!segmentImage && !segmentVideo && !segmentGif) minScopedGeneric = true;
}
}
+ if (hasBoundedCountRange) {
+ if (boundedRangeKind === 'image') minScopedImage = true;
+ else if (boundedRangeKind === 'video') minScopedVideo = true;
+ else if (boundedRangeKind === 'gif') minScopedGif = true;
+ else minScopedGeneric = true;
+ }
const isMinimumCount = isGeneric && hasMinCountQualifier;
const isImageMinimum = isGeneric && (minScopedImage || minScopedGeneric);
const isVideoMinimum = isGeneric && (minScopedVideo || minScopedGeneric);
@@ -2901,6 +2927,12 @@ export class Agent extends LoopDetector {
if (!segmentImage && !segmentVideo && !segmentGif) maxScopedGeneric = true;
}
}
+ if (hasBoundedCountRange) {
+ if (boundedRangeKind === 'image') maxScopedImage = true;
+ else if (boundedRangeKind === 'video') maxScopedVideo = true;
+ else if (boundedRangeKind === 'gif') maxScopedGif = true;
+ else maxScopedGeneric = true;
+ }
const isMaximumCount = isGeneric && hasMaxCountQualifier;
const isImageMaximum = isGeneric && (maxScopedImage || maxScopedGeneric);
const isVideoMaximum = isGeneric && (maxScopedVideo || maxScopedGeneric);
@@ -3009,6 +3041,10 @@ export class Agent extends LoopDetector {
if (!isAlternative && wantsImage && wantsVideo && expectedCount < 2) {
expectedCount = 2;
}
+ if (hasBoundedCountRange) {
+ expectedCount = rangeMaximumCount;
+ if (boundedRangeKind === 'generic') hasExplicitGenericCount = true;
+ }
} else {
const specificTargets = this._parseSpecificAttachmentTargets(rawVal);
// Word joiners need surrounding whitespace so a filename such as
@@ -3019,10 +3055,10 @@ export class Agent extends LoopDetector {
.map(group => this._parseSpecificAttachmentTargets(group))
.filter(group => group.length > 0)
: [];
- // In "logo.png and either chart.png or graph.png", `either` scopes the
- // choice while everything before it remains a requirement in both
- // branches. Distribute that shared prefix instead of parsing ordinary
- // AND-before-OR precedence and accidentally accepting graph.png alone.
+ // In "logo.png and either chart.png or graph.png, and caption.png",
+ // `either` scopes the choice while the surrounding conjuncts remain
+ // requirements in both branches. Distribute both sides instead of
+ // accepting a branch that omits a shared file.
if (specificTargetAlternatives.length > 1) {
const eitherIndex = specificTargetAlternatives[0]
.findIndex(target => /^(?:either|one\s+of)\s+/iu.test(target));
@@ -3030,8 +3066,28 @@ export class Agent extends LoopDetector {
const sharedPrefix = specificTargetAlternatives[0].slice(0, eitherIndex);
const firstChoice = specificTargetAlternatives[0].slice(eitherIndex);
firstChoice[0] = firstChoice[0].replace(/^(?:either|one\s+of)\s+/iu, '');
- specificTargetAlternatives = [firstChoice, ...specificTargetAlternatives.slice(1)]
- .map(group => [...sharedPrefix, ...group]);
+ const choiceGroups = [firstChoice, ...specificTargetAlternatives.slice(1)];
+ const maskedTargets = this._maskQuotedPayload(String(rawVal || ''));
+ const trailingConjunct = /[,;]\s*(?:and|plus|also|as\s+well\s+as)\s+/giu;
+ let trailingBoundary = null;
+ for (const match of maskedTargets.matchAll(trailingConjunct)) trailingBoundary = match;
+ const sharedSuffix = trailingBoundary
+ ? this._parseSpecificAttachmentTargets(
+ String(rawVal || '').slice((trailingBoundary.index || 0) + trailingBoundary[0].length),
+ )
+ : [];
+ if (sharedSuffix.length > 0) {
+ const lastGroup = choiceGroups[choiceGroups.length - 1];
+ const suffixStart = lastGroup.length - sharedSuffix.length;
+ const suffixIsTail = suffixStart >= 1 && sharedSuffix.every(
+ (target, index) => lastGroup[suffixStart + index] === target,
+ );
+ if (suffixIsTail) choiceGroups[choiceGroups.length - 1] = lastGroup.slice(0, suffixStart);
+ else sharedSuffix.length = 0;
+ }
+ specificTargetAlternatives = choiceGroups.map(group => (
+ [...new Set([...sharedPrefix, ...group, ...sharedSuffix])]
+ ));
}
}
if (specificTargetAlternatives.length > 1) {
@@ -3077,6 +3133,10 @@ export class Agent extends LoopDetector {
isImageMaximum,
isVideoMaximum,
isGifMaximum,
+ hasBoundedCountRange,
+ minimumCount: hasBoundedCountRange ? rangeMinimumCount : 0,
+ maximumCount: hasBoundedCountRange ? rangeMaximumCount : 0,
+ boundedRangeKind,
wantsImage,
wantsVideo,
wantsOrdinaryVideo,
@@ -3165,7 +3225,8 @@ export class Agent extends LoopDetector {
// 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.
- const allowsNoAttachments = parsed.isGeneric && (
+ const allowsNoAttachments = parsed.isGeneric
+ && !(parsed.hasBoundedCountRange && parsed.minimumCount > 0) && (
parsed.isAlternative
? (parsed.isMaximumCount
|| (parsed.wantsImage && parsed.isImageMaximum)
@@ -3248,6 +3309,13 @@ export class Agent extends LoopDetector {
const videoCount = rawAttachments.filter(isVideoAttachment).length;
const gifCount = rawAttachments.filter(isGifAttachment).length;
const ordinaryVideoCount = rawAttachments.filter(att => isVideoAttachment(att) && !isGifAttachment(att)).length;
+ if (parsed.hasBoundedCountRange) {
+ const boundedCount = parsed.boundedRangeKind === 'image' ? imageCount
+ : parsed.boundedRangeKind === 'video' ? ordinaryVideoCount
+ : parsed.boundedRangeKind === 'gif' ? gifCount
+ : rawAttachments.length;
+ if (boundedCount < parsed.minimumCount || boundedCount > parsed.maximumCount) return false;
+ }
if (parsed.wantsGif) {
const requiredGifCount = parsed.alternativeCounts?.length
? Math.min(...parsed.alternativeCounts)
@@ -14682,6 +14750,9 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (!isCoordinated) carriedNegation = false;
const publish = c.maskedText.match(SOCIAL_PUBLISH_VERBS);
+ const hasExplicitAffirmative = Boolean(
+ publish && /(?<![\p{L}\p{N}_])do\s*$/iu.test(c.maskedText.slice(0, publish.index)),
+ );
let hasExplicitNeg = false;
if (publish) {
const beforeVerb = c.maskedText.slice(0, publish.index);
@@ -14694,10 +14765,14 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (hasExplicitNeg) {
c.isNegated = true;
carriedNegation = true;
- } else if (carriedNegation) {
+ } else if (carriedNegation && !hasExplicitAffirmative) {
c.isNegated = true;
} else {
c.isNegated = false;
+ // An explicit affirmative publish clause ("and do post...") starts a
+ // new polarity scope. Elliptical coordinated destinations still
+ // inherit the preceding negation.
+ if (hasExplicitAffirmative) carriedNegation = false;
}
}
diff --git a/test/run.js b/test/run.js
index c803daa4f..59ce9e237 100644
--- a/test/run.js
+++ b/test/run.js
@@ -90787,6 +90787,8 @@ test('social publication workflow follows the live X or Bluesky destination and
'multiple publish destinations joined by or under negation were wrongly treated as a publish destination'],
['Do not post on X, but publish on Bluesky', ['bluesky'],
'contrastive but clause after negated post was wrongly rejected for Bluesky'],
+ ['Do not post on X and do post on Bluesky', ['bluesky'],
+ 'explicit affirmative publish clause inherited negation from X'],
['Post or publish this on X', ['twitter'],
'affirmative coordinated publish verbs were wrongly rejected for X'],
['Post "Do not panic" on X', ['twitter'],
@@ -92870,6 +92872,32 @@ test('upper-bound attachment qualifiers verify as maximum counts', () => {
assert.equal(agent._workflowSocialPublishedAttachmentObserved(
{ value: 'up to two videos' }, { attachments: [] }), true,
AgentClass.name + ': zero videos should satisfy a standalone video maximum');
+
+ const boundedImages = agent._parseWorkflowAttachmentRequirement('between one and two images');
+ assert.equal(boundedImages.isGeneric, true,
+ AgentClass.name + ': bounded image range was parsed as filenames');
+ assert.equal(boundedImages.hasBoundedCountRange, true,
+ AgentClass.name + ': bounded image range marker was lost');
+ assert.equal(boundedImages.minimumCount, 1,
+ AgentClass.name + ': bounded image lower limit was lost');
+ assert.equal(boundedImages.maximumCount, 2,
+ AgentClass.name + ': bounded image upper limit was lost');
+ assert.equal(boundedImages.boundedRangeKind, 'image',
+ AgentClass.name + ': bounded image range was not scoped to images');
+ assert.deepEqual(boundedImages.specificTargets, [],
+ AgentClass.name + ': bounded image range created filename targets');
+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(
+ { value: 'between one and two images' }, { attachments: [image(1)] }), true,
+ AgentClass.name + ': one image should satisfy the bounded range');
+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(
+ { value: 'between one and two images' }, { attachments: [image(1), image(2)] }), true,
+ AgentClass.name + ': two images should satisfy the bounded range');
+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(
+ { value: 'between one and two images' }, { attachments: [] }), false,
+ AgentClass.name + ': zero images satisfied a positive bounded range');
+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(
+ { value: 'between one and two images' }, { attachments: [image(1), image(2), image(3)] }), false,
+ AgentClass.name + ': three images exceeded the bounded range');
assert.equal(agent._workflowSocialPublishedAttachmentObserved(
{ value: 'up to two GIFs' }, { attachments: [] }), true,
AgentClass.name + ': zero GIFs should satisfy a standalone GIF maximum');
@@ -93339,6 +93367,33 @@ test('attachment verification matches specific attachment names without substrin
false,
AgentClass.name + ': alternative file alone satisfied a missing shared conjunct',
);
+ const trailingSharedConjunct = agent._parseWorkflowAttachmentRequirement(
+ 'either chart.png or graph.png, and logo.png',
+ );
+ assert.deepEqual(trailingSharedConjunct.specificTargetAlternatives,
+ [['chart.png', 'logo.png'], ['graph.png', 'logo.png']],
+ AgentClass.name + ': trailing shared conjunct was not retained in every alternative branch');
+ assert.equal(
+ agent._workflowSocialPublishedAttachmentObserved(
+ { value: 'either chart.png or graph.png, and logo.png' },
+ {
+ attachments: [
+ { type: 'image', src: 'https://pbs.twimg.com/media/chart.png' },
+ { type: 'image', src: 'https://pbs.twimg.com/media/logo.png' },
+ ],
+ },
+ ),
+ true,
+ AgentClass.name + ': valid choice plus trailing shared conjunct was rejected',
+ );
+ assert.equal(
+ agent._workflowSocialPublishedAttachmentObserved(
+ { value: 'either chart.png or graph.png, and logo.png' },
+ { attachments: [{ type: 'image', src: 'https://pbs.twimg.com/media/chart.png' }] },
+ ),
+ false,
+ AgentClass.name + ': choice without trailing shared conjunct was accepted',
+ );
for (const [allowedName, type] of [['chart.png', 'image'], ['clip.mp4', 'video']]) {
assert.equal(
agent._workflowSocialPublishedAttachmentObserved(