Skip to content

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

fix(agent): recognize Portuguese 'no' destination preposition

Emre Sokulluc62b447c6ee2
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index fef86f0ee..2ebac1dad 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -305,7 +305,7 @@ const CJK_GENERIC_ATTACHMENT_REGEX = /^[0-9一二两三四五六七八九十添
// "On <url>, publish this" names a destination just as plainly as
// "publish this on <url>", but only when the URL is presented as a place.
const SOCIAL_PUBLISH_DESTINATION_LEAD = new RegExp(
- '(?:^|[\\s,;:(\\[\'"])(?:on|onto|to|via|en|\u00e0|au|auf|su|em|na|para|\u0432|\u043d\u0430)\\s+$'
+ '(?:^|[\\s,;:(\\[\'"])(?:on|onto|to|via|en|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)\\s+$'
+ '|[\u3067\u306b\u4e0a\u5728\u5230\u81f3]\\s*$',
'iu',
);
@@ -15354,7 +15354,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const clauses = this._socialPublicationClauses(trustedContext);
const publishesTo = (platform) => {
const platformPattern = new RegExp(
- `(?<![${SOCIAL_WORD_EDGE}])(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|para|\u0432|\u043d\u0430)(?![${SOCIAL_WORD_EDGE}])\\s+(?:the\\s+)?${platform}(?![${SOCIAL_WORD_EDGE}])`
+ `(?<![${SOCIAL_WORD_EDGE}])(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)(?![${SOCIAL_WORD_EDGE}])\\s+(?:the\\s+)?${platform}(?![${SOCIAL_WORD_EDGE}])`
+ `|[\\u5230\\u81f3\\u5728]\\s*${platform}(?![a-z0-9_])`
+ `|(?:\u5728\\s*)?${platform}\\s*[\\u306b\\u3078\\u3067\\u4e0a\\uc5d0\\ub85c](?![a-z0-9_])`
+ `|${platform}\\s*\\uc73c\\ub85c(?![a-z0-9_])`,
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 3b40e82f0..298485142 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -238,7 +238,7 @@ const CJK_GENERIC_ATTACHMENT_REGEX = /^[0-9一二两三四五六七八九十添
// "On <url>, publish this" names a destination just as plainly as
// "publish this on <url>", but only when the URL is presented as a place.
const SOCIAL_PUBLISH_DESTINATION_LEAD = new RegExp(
- '(?:^|[\\s,;:(\\[\'"])(?:on|onto|to|via|en|\u00e0|au|auf|su|em|na|para|\u0432|\u043d\u0430)\\s+$'
+ '(?:^|[\\s,;:(\\[\'"])(?:on|onto|to|via|en|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)\\s+$'
+ '|[\u3067\u306b\u4e0a\u5728\u5230\u81f3]\\s*$',
'iu',
);
@@ -13154,7 +13154,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const clauses = this._socialPublicationClauses(trustedContext);
const publishesTo = (platform) => {
const platformPattern = new RegExp(
- `(?<![${SOCIAL_WORD_EDGE}])(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|para|\u0432|\u043d\u0430)(?![${SOCIAL_WORD_EDGE}])\\s+(?:the\\s+)?${platform}(?![${SOCIAL_WORD_EDGE}])`
+ `(?<![${SOCIAL_WORD_EDGE}])(?:on|onto|to|via|in|at|en|sur|sobre|\u00e0|au|auf|su|em|na|no|nos|nas|para|\u0432|\u043d\u0430)(?![${SOCIAL_WORD_EDGE}])\\s+(?:the\\s+)?${platform}(?![${SOCIAL_WORD_EDGE}])`
+ `|[\\u5230\\u81f3\\u5728]\\s*${platform}(?![a-z0-9_])`
+ `|(?:\u5728\\s*)?${platform}\\s*[\\u306b\\u3078\\u3067\\u4e0a\\uc5d0\\ub85c](?![a-z0-9_])`
+ `|${platform}\\s*\\uc73c\\ub85c(?![a-z0-9_])`,
diff --git a/test/run.js b/test/run.js
index 64d666d0a..290fe45a3 100644
--- a/test/run.js
+++ b/test/run.js
@@ -86390,6 +86390,12 @@ test('social publication workflow follows the live X or Bluesky destination and
'long quoted body before on https://x.com/home was cut off by character window'],
['Post "This is a very long announcement body that contains far more than fifty or sixty characters and explains everything clearly" to https://bsky.app/', ['bluesky'],
'long quoted body before to https://bsky.app/ was cut off by character window'],
+ ['Publique no X: olá', ['twitter'],
+ 'Portuguese no X destination preposition was not recognized'],
+ ['Publique na Bluesky: olá', ['bluesky'],
+ 'Portuguese na Bluesky destination preposition was not recognized'],
+ ['Não publique no X: olá', [],
+ 'negated Portuguese no X command was wrongly treated as a publish destination'],
]) {
assert.deepEqual(
[...agent._trustedSocialPublishTargetAdapters({ taskText })],