Skip to content

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

fix(social-publish): accept except-for exclusions and scope format maxima

Barack Sokullu3f4f80c5012e
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index c4e511b55..2385d2627 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|skip|skipping|omit|omitting|except|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|omit|omitting|except|no)\s+(?:for\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 || ''))
@@ -4435,7 +4435,7 @@ export class Agent extends LoopDetector {
if (imageCount !== parsed.expectedCount || rawAttachments.length !== parsed.expectedCount) {
return false;
}
- } else if (parsed.isImageMaximum || parsed.isMaximumCount) {
+ } else if (parsed.isImageMaximum || (parsed.isMaximumCount && parsed.maximumGenericCount > 0)) {
const maximumCount = imageMaximumBound || parsed.maximumGenericCount || parsed.expectedCount;
if (imageCount > maximumCount || rawAttachments.length > maximumCount) {
return false;
@@ -4488,7 +4488,7 @@ export class Agent extends LoopDetector {
if (typedVideoCount !== parsed.expectedCount || rawAttachments.length !== parsed.expectedCount) {
return false;
}
- } else if (parsed.isVideoMaximum || parsed.isGifMaximum || parsed.isMaximumCount) {
+ } else if (parsed.isVideoMaximum || parsed.isGifMaximum || (parsed.isMaximumCount && parsed.maximumGenericCount > 0)) {
const maximumCount = requiresGifOnly
? gifMaximumBound
: (ordinaryVideoOnly ? videoMaximumBound : (videoMaximumBound + gifMaximumBound))
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index e6cb2de5e..444a94ccf 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|skip|skipping|omit|omitting|except|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|omit|omitting|except|no)\s+(?:for\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 || ''))
@@ -4150,7 +4150,7 @@ export class Agent extends LoopDetector {
if (imageCount !== parsed.expectedCount || rawAttachments.length !== parsed.expectedCount) {
return false;
}
- } else if (parsed.isImageMaximum || parsed.isMaximumCount) {
+ } else if (parsed.isImageMaximum || (parsed.isMaximumCount && parsed.maximumGenericCount > 0)) {
const maximumCount = imageMaximumBound || parsed.maximumGenericCount || parsed.expectedCount;
if (imageCount > maximumCount || rawAttachments.length > maximumCount) {
return false;
@@ -4203,7 +4203,7 @@ export class Agent extends LoopDetector {
if (typedVideoCount !== parsed.expectedCount || rawAttachments.length !== parsed.expectedCount) {
return false;
}
- } else if (parsed.isVideoMaximum || parsed.isGifMaximum || parsed.isMaximumCount) {
+ } else if (parsed.isVideoMaximum || parsed.isGifMaximum || (parsed.isMaximumCount && parsed.maximumGenericCount > 0)) {
const maximumCount = requiresGifOnly
? gifMaximumBound
: (ordinaryVideoOnly ? videoMaximumBound : (videoMaximumBound + gifMaximumBound))
diff --git a/test/run.js b/test/run.js
index 2f29dcbdd..fc4a2459e 100644
--- a/test/run.js
+++ b/test/run.js
@@ -90837,6 +90837,10 @@ test('social publication workflow follows the live X or Bluesky destination and
'an except clause adopted its forbidden X destination'],
['Post on X, except Bluesky', ['twitter'],
'an except clause adopted its forbidden Bluesky destination'],
+ ['Post on X, except for Bluesky', ['twitter'],
+ 'an except-for clause adopted its forbidden Bluesky destination'],
+ ['Post on Bluesky, except for X', ['bluesky'],
+ 'an except-for clause adopted its forbidden X 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'],
@@ -93182,6 +93186,28 @@ test('upper-bound attachment qualifiers verify as maximum counts', () => {
{ value: 'one PNG image and one image' }, { attachments },
), expected, AgentClass.name + ': ' + message);
}
+ for (const [attachments, expected, message] of [
+ [[image(1)], true, 'the required PNG alone was rejected by its scoped JPEG cap'],
+ [[image(1), { type: 'image', src: 'https://cdn.example/a.jpg' }], true, 'a PNG plus a capped JPEG was capped by the total image count'],
+ [[image(1), { type: 'image', src: 'https://cdn.example/a.jpg' }, { type: 'image', src: 'https://cdn.example/b.jpg' }], true, 'a PNG plus two capped JPEGs was capped by the total image count'],
+ [[image(1), { type: 'image', src: 'https://cdn.example/a.jpg' }, { type: 'image', src: 'https://cdn.example/b.jpg' }, { type: 'image', src: 'https://cdn.example/c.jpg' }], false, 'too many JPEGs satisfied the scoped JPEG cap'],
+ [[{ type: 'image', src: 'https://cdn.example/a.jpg' }], false, 'a lone JPEG satisfied the required PNG minimum'],
+ ]) {
+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(
+ { value: 'at least one PNG image and at most two JPEG images' }, { attachments },
+ ), expected, AgentClass.name + ': ' + message);
+ }
+ for (const [attachments, expected, message] of [
+ [[video(1)], true, 'the required MP4 alone was rejected by its scoped MOV cap'],
+ [[video(1), { type: 'video', src: 'https://cdn.example/b.mov' }], true, 'an MP4 plus a capped MOV was capped by the total video count'],
+ [[video(1), { type: 'video', src: 'https://cdn.example/b.mov' }, { type: 'video', src: 'https://cdn.example/c.mov' }], true, 'an MP4 plus two capped MOVs was capped by the total video count'],
+ [[video(1), { type: 'video', src: 'https://cdn.example/b.mov' }, { type: 'video', src: 'https://cdn.example/c.mov' }, { type: 'video', src: 'https://cdn.example/d.mov' }], false, 'too many MOVs satisfied the scoped MOV cap'],
+ [[{ type: 'video', src: 'https://cdn.example/b.mov' }], false, 'a lone MOV satisfied the required MP4 minimum'],
+ ]) {
+ assert.equal(agent._workflowSocialPublishedAttachmentObserved(
+ { value: 'at least one MP4 video and at most two MOV videos' }, { attachments },
+ ), expected, AgentClass.name + ': ' + message);
+ }
const imageButNoVideo = agent._parseWorkflowAttachmentRequirement('one image but no video');
assert.equal(imageButNoVideo.isGeneric, true,
AgentClass.name + ': contrastive media conjunction was parsed as a filename');