Skip to content

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

fix(social-publish): modal command prefix, and-if fallback

Barack Sokulluc30c8da84ee0
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 0b2fb1516..574a793c2 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -18096,9 +18096,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (inColonBodyScope) {
const clauseDelim = clause.delim || '';
const leadText = String(clause.maskedText || clause.text || '').trimStart();
- // A polite prefix ("Please post this on Bluesky.") is still a new
- // command: look past it before deciding the sentence stays prose.
- const commandLeadText = leadText.replace(/^(?:please|kindly)\b[\s,]+/iu, '');
+ // A polite or modal prefix ("Please post this on Bluesky.",
+ // "Could you post this on Bluesky?") still opens a new command:
+ // look past it before deciding the sentence stays prose.
+ const commandLeadText = leadText.replace(/^(?:(?:please|kindly|(?:could|can|would|will|shall|should|may|might)(?:\s+you)?)\b[\s,]+)+/iu, '');
const leadsWithPublish = startsWithPublishVerb.test(commandLeadText)
&& !SOCIAL_PROPER_NAME_PROSE_LEAD.test(commandLeadText);
if (!SOCIAL_COORDINATING_DELIMITER.test(clauseDelim)
@@ -18308,7 +18309,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// Only list-shaped glue may sit between the two platform mentions. An
// unrelated branch such as "X or report the blocker; also post on
// Bluesky" contains `or`, but it does not coordinate the destinations.
- const directAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:(?:[,;]|[.!?](?=\s*(?:if|unless|but)\b))\s*)?(?:(?:but\s+)?(?:if\s+(?:(?:that|it|this)\s+)?(?:unavailable|not\s+available|not\s+work(?:ing|s)?|(?:do|does|did)\s+not\s+work|(?:do|does|did)n['’]?t\s+work|available|needed|necessary|possible|possibly|unable|unsuccessful|failing|failed|fails?|failure)\b[^,;]*,?\s*)(?:(?:or|otherwise|failing\s+that|oder|ou|o|oppure|veya|ya\s+da|\u0438\u043b\u0438|\u043b\u0438\u0431\u043e)(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740))?|(?:(?:or|otherwise|failing\s+that|oder|ou|o|oppure|veya|ya\s+da|\u0438\u043b\u0438|\u043b\u0438\u0431\u043e)(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740))|(?:but\s+)?(?:unless\s+[^,;]*,\s*then\s*))\s*(?:,\s*)?(?:(?:alternatively|otherwise|else)(?:\s*,\s*|\s+))?(?:,\s*if\s+(?:(?:that|it|this)\s+)?(?:unavailable|not\s+available|not\s+work(?:ing|s)?|(?:do|does|did)\s+not\s+work|(?:do|does|did)n['’]?t\s+work|available|needed|necessary|possible|unable|unsuccessful|failing|failed|fails?|failure)\b[^,;]*,?\s*)?(?:(?:post|publish|share|tweet|send|reply|respond)\s+(?:(?:this|that|it|the\s+following)\s+)?)?(?:(?:also\s+)?(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)\s+)?(?:the\s+)?$/iu;
+ const directAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:(?:[,;]|[.!?](?=\s*(?:if|unless|but|and)\b))\s*)?(?:(?:(?:but|and)\s+)?(?:if\s+(?:(?:that|it|this)\s+)?(?:unavailable|not\s+available|not\s+work(?:ing|s)?|(?:do|does|did)\s+not\s+work|(?:do|does|did)n['’]?t\s+work|available|needed|necessary|possible|possibly|unable|unsuccessful|failing|failed|fails?|failure)\b[^,;]*,?\s*)(?:(?:or|otherwise|failing\s+that|oder|ou|o|oppure|veya|ya\s+da|\u0438\u043b\u0438|\u043b\u0438\u0431\u043e)(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740))?|(?:(?:or|otherwise|failing\s+that|oder|ou|o|oppure|veya|ya\s+da|\u0438\u043b\u0438|\u043b\u0438\u0431\u043e)(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740))|(?:(?:but|and)\s+)?(?:unless\s+[^,;]*,\s*then\s*))\s*(?:,\s*)?(?:(?:alternatively|otherwise|else)(?:\s*,\s*|\s+))?(?:,\s*if\s+(?:(?:that|it|this)\s+)?(?:unavailable|not\s+available|not\s+work(?:ing|s)?|(?:do|does|did)\s+not\s+work|(?:do|does|did)n['’]?t\s+work|available|needed|necessary|possible|unable|unsuccessful|failing|failed|fails?|failure)\b[^,;]*,?\s*)?(?:(?:post|publish|share|tweet|send|reply|respond)\s+(?:(?:this|that|it|the\s+following)\s+)?)?(?:(?:also\s+)?(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)\s+)?(?:the\s+)?$/iu;
const explicitAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:,\s*)?(?:(?:alternatively|otherwise|failing\s+that)(?:\s*,\s*)?(?:[\s,]+(?:on|onto|to|via|in|at))?|as\s+an\s+alternative\s+to)\s*(?:the\s+)?$/iu;
const oneOfAlternativeLead = /(?<![\p{L}\p{N}_])one\s+of\s+(?:the\s+)?$/iu;
const oneOfAlternativeBridge = /^\s*(?:,\s*)?(?:and|or)\s+(?:the\s+)?$/iu;
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 04d2719f4..4357832c5 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -15895,9 +15895,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (inColonBodyScope) {
const clauseDelim = clause.delim || '';
const leadText = String(clause.maskedText || clause.text || '').trimStart();
- // A polite prefix ("Please post this on Bluesky.") is still a new
- // command: look past it before deciding the sentence stays prose.
- const commandLeadText = leadText.replace(/^(?:please|kindly)\b[\s,]+/iu, '');
+ // A polite or modal prefix ("Please post this on Bluesky.",
+ // "Could you post this on Bluesky?") still opens a new command:
+ // look past it before deciding the sentence stays prose.
+ const commandLeadText = leadText.replace(/^(?:(?:please|kindly|(?:could|can|would|will|shall|should|may|might)(?:\s+you)?)\b[\s,]+)+/iu, '');
const leadsWithPublish = startsWithPublishVerb.test(commandLeadText)
&& !SOCIAL_PROPER_NAME_PROSE_LEAD.test(commandLeadText);
if (!SOCIAL_COORDINATING_DELIMITER.test(clauseDelim)
@@ -16107,7 +16108,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
// Only list-shaped glue may sit between the two platform mentions. An
// unrelated branch such as "X or report the blocker; also post on
// Bluesky" contains `or`, but it does not coordinate the destinations.
- const directAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:(?:[,;]|[.!?](?=\s*(?:if|unless|but)\b))\s*)?(?:(?:but\s+)?(?:if\s+(?:(?:that|it|this)\s+)?(?:unavailable|not\s+available|not\s+work(?:ing|s)?|(?:do|does|did)\s+not\s+work|(?:do|does|did)n['’]?t\s+work|available|needed|necessary|possible|possibly|unable|unsuccessful|failing|failed|fails?|failure)\b[^,;]*,?\s*)(?:(?:or|otherwise|failing\s+that|oder|ou|o|oppure|veya|ya\s+da|\u0438\u043b\u0438|\u043b\u0438\u0431\u043e)(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740))?|(?:(?:or|otherwise|failing\s+that|oder|ou|o|oppure|veya|ya\s+da|\u0438\u043b\u0438|\u043b\u0438\u0431\u043e)(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740))|(?:but\s+)?(?:unless\s+[^,;]*,\s*then\s*))\s*(?:,\s*)?(?:(?:alternatively|otherwise|else)(?:\s*,\s*|\s+))?(?:,\s*if\s+(?:(?:that|it|this)\s+)?(?:unavailable|not\s+available|not\s+work(?:ing|s)?|(?:do|does|did)\s+not\s+work|(?:do|does|did)n['’]?t\s+work|available|needed|necessary|possible|unable|unsuccessful|failing|failed|fails?|failure)\b[^,;]*,?\s*)?(?:(?:post|publish|share|tweet|send|reply|respond)\s+(?:(?:this|that|it|the\s+following)\s+)?)?(?:(?:also\s+)?(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)\s+)?(?:the\s+)?$/iu;
+ const directAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:(?:[,;]|[.!?](?=\s*(?:if|unless|but|and)\b))\s*)?(?:(?:(?:but|and)\s+)?(?:if\s+(?:(?:that|it|this)\s+)?(?:unavailable|not\s+available|not\s+work(?:ing|s)?|(?:do|does|did)\s+not\s+work|(?:do|does|did)n['’]?t\s+work|available|needed|necessary|possible|possibly|unable|unsuccessful|failing|failed|fails?|failure)\b[^,;]*,?\s*)(?:(?:or|otherwise|failing\s+that|oder|ou|o|oppure|veya|ya\s+da|\u0438\u043b\u0438|\u043b\u0438\u0431\u043e)(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740))?|(?:(?:or|otherwise|failing\s+that|oder|ou|o|oppure|veya|ya\s+da|\u0438\u043b\u0438|\u043b\u0438\u0431\u043e)(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740))|(?:(?:but|and)\s+)?(?:unless\s+[^,;]*,\s*then\s*))\s*(?:,\s*)?(?:(?:alternatively|otherwise|else)(?:\s*,\s*|\s+))?(?:,\s*if\s+(?:(?:that|it|this)\s+)?(?:unavailable|not\s+available|not\s+work(?:ing|s)?|(?:do|does|did)\s+not\s+work|(?:do|does|did)n['’]?t\s+work|available|needed|necessary|possible|unable|unsuccessful|failing|failed|fails?|failure)\b[^,;]*,?\s*)?(?:(?:post|publish|share|tweet|send|reply|respond)\s+(?:(?:this|that|it|the\s+following)\s+)?)?(?:(?:also\s+)?(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)\s+)?(?:the\s+)?$/iu;
const explicitAlternativeBridge = /^\s*(?:(?:page|account|profile)\s*)?(?:,\s*)?(?:(?:alternatively|otherwise|failing\s+that)(?:\s*,\s*)?(?:[\s,]+(?:on|onto|to|via|in|at))?|as\s+an\s+alternative\s+to)\s*(?:the\s+)?$/iu;
const oneOfAlternativeLead = /(?<![\p{L}\p{N}_])one\s+of\s+(?:the\s+)?$/iu;
const oneOfAlternativeBridge = /^\s*(?:,\s*)?(?:and|or)\s+(?:the\s+)?$/iu;
diff --git a/test/run.js b/test/run.js
index 8482b39cf..6d3a1e90b 100644
--- a/test/run.js
+++ b/test/run.js
@@ -91033,6 +91033,8 @@ test('social publication workflow follows the live X or Bluesky destination and
'hyphenated prose left colon scope and adopted Bluesky'],
['Post on X: Hello. Please post this on Bluesky.', ['twitter', 'bluesky'],
'a polite follow-up command stayed inside the first body scope'],
+ ['Post on X: Hello. Could you post this on Bluesky?', ['twitter', 'bluesky'],
+ 'a modal follow-up command stayed inside the first body scope'],
['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'],
@@ -91442,6 +91444,10 @@ test('alternative social destinations require one verified publication, not ever
...guard,
taskText: 'Post on X, but if it fails, post on Bluesky.',
}), true, AgentClass.name + ': but-if fallback required a second public post');
+ assert.equal(agent._socialPublishTargetsAreAlternatives({
+ ...guard,
+ taskText: 'Post on X, and if that fails, post on Bluesky.',
+ }), true, AgentClass.name + ': coordinated conditional fallback required a second public post');
assert.equal(agent._socialPublishTargetsAreAlternatives({
...guard,
taskText: 'Post hello on X and Bluesky. Compare X or Bluesky afterward.',