Skip to content

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

Scope message and public-post guards

Emre Sokullu154e715c2522
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index ca1c0acdf..2b9aa6e86 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -23194,7 +23194,24 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
supportsRecipientSets: policy.supportsRecipientSets === true,
...(target?.target_kind === 'named' ? { expectedRecipients: target.recipients } : {}),
});
- if (probe?.success === true && probe?.conclusive === true && probe.messageSend === false) return null;
+ if (probe?.success === true && probe?.conclusive === true && probe.messageSend === false) {
+ const linkedInPublicPost = policy.adapterName === 'linkedin' && probe.publicPost === true;
+ const publishWorkflowAuthorized = guard?.siteWorkflow?.adapterName === 'linkedin'
+ && guard?.siteWorkflow?.job?.id === 'publish-post';
+ // A public Post control is not a message send, but it is still a
+ // consequential action. Only the explicit LinkedIn publish workflow can
+ // bypass recipient dispatch binding for that control.
+ if (!linkedInPublicPost || publishWorkflowAuthorized) return null;
+ return {
+ success: false,
+ blocked: true,
+ noDispatch: true,
+ dispatched: false,
+ messageRecipientGuard: true,
+ reasonCode: 'public_post_not_authorized',
+ error: 'LinkedIn Post blocked because this task authorizes a private message, not a public post.',
+ };
+ }
// Gmail reply editors can be collapsed when planning begins. Allow only a
// content-verified Reply/Reply all/Forward control to open the editor;
// every other unresolved click remains blocked. Recipient authorization
@@ -28240,10 +28257,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
: (sawNamedSocialPlatform ? [] : rawCandidates);
let bestBody = '';
// A direct-message task can omit the platform when the active workflow
- // already binds the X conversation ("Send Alex: Hello there"). Treat
- // that imperative like the existing message/publish forms so an explicit
- // body remains subject to the same exact dispatch verification.
- const publishVerbPattern = `(?:${SOCIAL_PUBLISH_VERBS.source}|message|send|update)`;
+ // already binds the X conversation ("Send Alex: Hello there"). Keep that
+ // imperative local to X: other message workflows may use "send" while
+ // separately naming subject/body fields, which this post-body extractor
+ // must not reinterpret as one combined body.
+ const publishVerbPattern = `(?:${SOCIAL_PUBLISH_VERBS.source}|message${adapterName === 'twitter' ? '|send' : ''}|update)`;
const quotedPattern = new RegExp(`${publishVerbPattern}[\\s\\S]*?(?:β€œ([\\s\\S]+?)”|γ€Œ([\\s\\S]+?)」|γ€Ž([\\s\\S]+?)』|Β«([\\s\\S]+?)Β»|"([\\s\\S]+?)")`, 'iu');
const singleQuotePattern = new RegExp(`${publishVerbPattern}[\\s\\S]*?(?:(?<!\\p{L})'([\\s\\S]+?)'(?!\\p{L}))`, 'iu');
const colonPattern = new RegExp(`${publishVerbPattern}[\\s\\S]*?(?<!https?|ftp|sftp)(?:(?<!\\d)[::]|[::](?!\\d{2}))(?!\\/\\/)\\s*([\\s\\S]+)$`, 'iu');
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 06e1ba1e5..037402210 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -20953,7 +20953,24 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
supportsRecipientSets: policy.supportsRecipientSets === true,
...(target?.target_kind === 'named' ? { expectedRecipients: target.recipients } : {}),
});
- if (probe?.success === true && probe?.conclusive === true && probe.messageSend === false) return null;
+ if (probe?.success === true && probe?.conclusive === true && probe.messageSend === false) {
+ const linkedInPublicPost = policy.adapterName === 'linkedin' && probe.publicPost === true;
+ const publishWorkflowAuthorized = guard?.siteWorkflow?.adapterName === 'linkedin'
+ && guard?.siteWorkflow?.job?.id === 'publish-post';
+ // A public Post control is not a message send, but it is still a
+ // consequential action. Only the explicit LinkedIn publish workflow can
+ // bypass recipient dispatch binding for that control.
+ if (!linkedInPublicPost || publishWorkflowAuthorized) return null;
+ return {
+ success: false,
+ blocked: true,
+ noDispatch: true,
+ dispatched: false,
+ messageRecipientGuard: true,
+ reasonCode: 'public_post_not_authorized',
+ error: 'LinkedIn Post blocked because this task authorizes a private message, not a public post.',
+ };
+ }
// Gmail reply editors can be collapsed when planning begins. Allow only a
// content-verified Reply/Reply all/Forward control to open the editor;
// every other unresolved click remains blocked. Recipient authorization
@@ -25854,10 +25871,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
: (sawNamedSocialPlatform ? [] : rawCandidates);
let bestBody = '';
// A direct-message task can omit the platform when the active workflow
- // already binds the X conversation ("Send Alex: Hello there"). Treat
- // that imperative like the existing message/publish forms so an explicit
- // body remains subject to the same exact dispatch verification.
- const publishVerbPattern = `(?:${SOCIAL_PUBLISH_VERBS.source}|message|send|update)`;
+ // already binds the X conversation ("Send Alex: Hello there"). Keep that
+ // imperative local to X: other message workflows may use "send" while
+ // separately naming subject/body fields, which this post-body extractor
+ // must not reinterpret as one combined body.
+ const publishVerbPattern = `(?:${SOCIAL_PUBLISH_VERBS.source}|message${adapterName === 'twitter' ? '|send' : ''}|update)`;
const quotedPattern = new RegExp(`${publishVerbPattern}[\\s\\S]*?(?:β€œ([\\s\\S]+?)”|γ€Œ([\\s\\S]+?)」|γ€Ž([\\s\\S]+?)』|Β«([\\s\\S]+?)Β»|"([\\s\\S]+?)")`, 'iu');
const singleQuotePattern = new RegExp(`${publishVerbPattern}[\\s\\S]*?(?:(?<!\\p{L})'([\\s\\S]+?)'(?!\\p{L}))`, 'iu');
const colonPattern = new RegExp(`${publishVerbPattern}[\\s\\S]*?(?<!https?|ftp|sftp)(?:(?<!\\d)[::]|[::](?!\\d{2}))(?!\\/\\/)\\s*([\\s\\S]+)$`, 'iu');
diff --git a/test/run.js b/test/run.js
index fd7d38b7c..2479a1bf6 100644
--- a/test/run.js
+++ b/test/run.js
@@ -5727,6 +5727,29 @@ test('direct-message recipient guard uses structured intent and exact active ide
`${label}: conclusively non-message Enter was incorrectly blocked`,
);
+ probe = { success: true, conclusive: true, messageSend: false, publicPost: true, identityCandidates: [] };
+ agent._planExecutionGuards.set(tabId, {
+ messaging: { target_kind: 'named', recipients: ['Ada'] },
+ requiresSubmission: true,
+ requiresStateChange: true,
+ siteWorkflow: resolveAdapterWorkflowJob('https://www.linkedin.com/feed/', 'send-message'),
+ });
+ const publicPostBlocked = await agent._messageRecipientGuardBlock(
+ tabId, 'click_ax', { ref_id: 'ref_linkedin_post' }, 'https://www.linkedin.com/feed/', {},
+ );
+ assert.equal(publicPostBlocked?.reasonCode, 'public_post_not_authorized',
+ `${label}: LinkedIn DM authorization allowed a public Post control`);
+ agent._planExecutionGuards.get(tabId).siteWorkflow = resolveAdapterWorkflowJob(
+ 'https://www.linkedin.com/feed/', 'publish-post',
+ );
+ assert.equal(
+ await agent._messageRecipientGuardBlock(
+ tabId, 'click_ax', { ref_id: 'ref_linkedin_post' }, 'https://www.linkedin.com/feed/', {},
+ ),
+ null,
+ `${label}: explicit LinkedIn publish workflow could not use its public Post control`,
+ );
+
probe = { success: true, conclusive: false, messageSend: null, identityCandidates: [] };
const inconclusive = await agent._messageRecipientGuardBlock(tabId, 'press_keys', { key: 'Enter' });
assert.equal(inconclusive?.reasonCode, 'message_send_classification_inconclusive', `${label}: inconclusive probe failed open`);
@@ -93926,6 +93949,11 @@ test('publication workflows classify and bind requested payload fields', async (
`${AgentClass.name}: the classifier did not require direct-message fields`);
assert.equal(agent._extractWorkflowTaskBody(xTask, '', 'twitter'), 'Hello there',
`${AgentClass.name}: a route-local Send command did not recover its explicit X DM body`);
+ assert.equal(
+ agent._extractWorkflowTaskBody('Send an email to Alice with subject: Hello and body: How are you?', '', 'gmail'),
+ '',
+ `${AgentClass.name}: X route-local Send recovery rewrote Gmail subject/body metadata`,
+ );
assert.deepEqual(xGuard.workflowMetadataRequirements, [
{ field: 'body', value: 'Hello there' },
], `${AgentClass.name}: an explicit X DM body was not bound after an empty classifier response`);