Skip to content

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

LinkedIn: a cross-site post binds the LinkedIn publish workflow first

Barack Sokullua3d4c8556af1
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 665556a83..b7d73dd94 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -3064,6 +3064,36 @@ export class Agent extends LoopDetector {
};
}
+ // A task that started on another site reaches LinkedIn's share composer
+ // with no LinkedIn workflow bound. Its post is held to what a LinkedIn
+ // task's post is: the live publish-post job is bound, as a GitHub
+ // conditional repair binds its commit job above, and what the post must
+ // contain is resolved for it. The post's submission record then binds its
+ // stable URL and payload (_workflowSubmitBindingForAttempt). Returns the
+ // bound workflow, or null when none can be bound.
+ async _adoptLiveLinkedInPublishWorkflow(tabId, pageUrl) {
+ const guard = this._planExecutionGuards.get(tabId);
+ if (!guard?.enabled || guard.siteWorkflow?.job) return null;
+ const live = this._resolvePlannerSiteWorkflow(pageUrl, { request_kind: 'execute', site_job: 'publish-post' });
+ if (live?.adapterName !== 'linkedin' || live.job?.id !== 'publish-post') return null;
+ guard.siteWorkflow = live;
+ guard.siteWorkflowUrl = pageUrl;
+ guard.requiresStateChange = true;
+ guard.requiresSubmission = true;
+ guard.verifiedSubmissionEvidence = false;
+ guard.workflowTerminalEvidence = null;
+ guard.workflowMetadataRequirementsResolved = false;
+ guard.workflowMetadataRequirementsIncomplete = true;
+ this._armWorkflowJobRequiredEvidence(tabId, guard);
+ const messages = this.conversations.get(tabId);
+ if (messages?.[0]?.role === 'system') messages[0].content = this._buildSystemPrompt(this._effectiveRunMode(tabId), tabId);
+ this._recordAdapterWorkflowTrace(this.currentRunId.get(tabId), live);
+ await this._ensureWorkflowMetadataRequirements(tabId, {
+ provider: this._activeProvider(tabId), costState: this.currentCostState.get(tabId) || null,
+ }, guard.taskText, pageUrl);
+ return live;
+ }
+
async _workflowPreSubmitDispatchBlock(tabId, name, args = {}, detectedSubmit = null, provider = this._activeProvider(tabId)) {
const socialBlock = await this._socialPublicationPreSubmitBlock(tabId, name, args, detectedSubmit, provider);
if (socialBlock) return socialBlock;
@@ -28680,15 +28710,37 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const linkedInPublicPost = policy.adapterName === 'linkedin' && probe.publicPost === true;
const publishWorkflowAuthorized = guard?.siteWorkflow?.adapterName === 'linkedin'
&& guard?.siteWorkflow?.job?.id === 'publish-post';
+ if (!linkedInPublicPost || publishWorkflowAuthorized) return null;
// A public Post control is not a message send, but it is still a
// consequential action. The explicit LinkedIn publish workflow
- // authorizes it, and so does a plan that requires a submission without
- // naming a private message to send: a task that started on another
- // site has no LinkedIn workflow yet. The normal submission gates still
- // apply to the post.
+ // authorizes it. A plan that requires a submission without naming a
+ // private message to send asks for it too, but a task that started on
+ // another site has no LinkedIn workflow yet. Its post is held to what a
+ // LinkedIn task's post is: the live publish-post job is bound first, so
+ // the post's stable URL and content are recorded and verified, and the
+ // click waits for the next turn under that job.
const planAuthorizesPublication = !!guard && guard.requiresSubmission === true
&& guard.requiresStateChange === true && !target;
- if (!linkedInPublicPost || publishWorkflowAuthorized || planAuthorizesPublication) return null;
+ const otherWorkflow = !!guard?.siteWorkflow?.job;
+ if (planAuthorizesPublication && !otherWorkflow) {
+ if (await this._adoptLiveLinkedInPublishWorkflow(tabId, resolvedPageUrl)) {
+ return {
+ success: false,
+ blocked: true,
+ noDispatch: true,
+ dispatched: false,
+ retryable: true,
+ workflowRearmed: true,
+ workflowJob: 'publish-post',
+ messageRecipientGuard: true,
+ reasonCode: 'publish_workflow_adopted',
+ error: 'Nothing was posted yet: this post now follows the LinkedIn publish workflow, so it can be verified once it is published. Read the composer again, check the exact text, then click Post.',
+ };
+ }
+ // With site adapters off no workflow can be bound, as on any other
+ // site; the normal submission gates still apply to the post.
+ if (!this.useSiteAdapters) return null;
+ }
return {
success: false,
blocked: true,
@@ -28698,7 +28750,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
reasonCode: 'public_post_not_authorized',
error: target
? 'LinkedIn Post blocked because this task authorizes a private message, not a public post.'
- : 'LinkedIn Post blocked because this task does not ask to publish anything, so nothing was posted. Do not post; report what is ready instead.',
+ : !planAuthorizesPublication
+ ? 'LinkedIn Post blocked because this task does not ask to publish anything, so nothing was posted. Do not post; report what is ready instead.'
+ : otherWorkflow
+ ? 'LinkedIn Post blocked because this run is set up for a different task, not a LinkedIn post, so nothing was posted. Do not post; report what is ready instead.'
+ : 'LinkedIn Post blocked because the LinkedIn publish workflow could not be bound, so nothing was posted. Do not post; report what is ready instead.',
};
}
// Gmail reply editors can be collapsed when planning begins. Allow only a
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 677471ba8..0777b0688 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -2621,6 +2621,36 @@ export class Agent extends LoopDetector {
};
}
+ // A task that started on another site reaches LinkedIn's share composer
+ // with no LinkedIn workflow bound. Its post is held to what a LinkedIn
+ // task's post is: the live publish-post job is bound, as a GitHub
+ // conditional repair binds its commit job above, and what the post must
+ // contain is resolved for it. The post's submission record then binds its
+ // stable URL and payload (_workflowSubmitBindingForAttempt). Returns the
+ // bound workflow, or null when none can be bound.
+ async _adoptLiveLinkedInPublishWorkflow(tabId, pageUrl) {
+ const guard = this._planExecutionGuards.get(tabId);
+ if (!guard?.enabled || guard.siteWorkflow?.job) return null;
+ const live = this._resolvePlannerSiteWorkflow(pageUrl, { request_kind: 'execute', site_job: 'publish-post' });
+ if (live?.adapterName !== 'linkedin' || live.job?.id !== 'publish-post') return null;
+ guard.siteWorkflow = live;
+ guard.siteWorkflowUrl = pageUrl;
+ guard.requiresStateChange = true;
+ guard.requiresSubmission = true;
+ guard.verifiedSubmissionEvidence = false;
+ guard.workflowTerminalEvidence = null;
+ guard.workflowMetadataRequirementsResolved = false;
+ guard.workflowMetadataRequirementsIncomplete = true;
+ this._armWorkflowJobRequiredEvidence(tabId, guard);
+ const messages = this.conversations.get(tabId);
+ if (messages?.[0]?.role === 'system') messages[0].content = this._buildSystemPrompt(this._effectiveRunMode(tabId), tabId);
+ this._recordAdapterWorkflowTrace(this.currentRunId.get(tabId), live);
+ await this._ensureWorkflowMetadataRequirements(tabId, {
+ provider: this._activeProvider(tabId), costState: this.currentCostState.get(tabId) || null,
+ }, guard.taskText, pageUrl);
+ return live;
+ }
+
async _workflowPreSubmitDispatchBlock(tabId, name, args = {}, detectedSubmit = null, provider = this._activeProvider(tabId)) {
const socialBlock = await this._socialPublicationPreSubmitBlock(tabId, name, args, detectedSubmit, provider);
if (socialBlock) return socialBlock;
@@ -25805,15 +25835,37 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const linkedInPublicPost = policy.adapterName === 'linkedin' && probe.publicPost === true;
const publishWorkflowAuthorized = guard?.siteWorkflow?.adapterName === 'linkedin'
&& guard?.siteWorkflow?.job?.id === 'publish-post';
+ if (!linkedInPublicPost || publishWorkflowAuthorized) return null;
// A public Post control is not a message send, but it is still a
// consequential action. The explicit LinkedIn publish workflow
- // authorizes it, and so does a plan that requires a submission without
- // naming a private message to send: a task that started on another
- // site has no LinkedIn workflow yet. The normal submission gates still
- // apply to the post.
+ // authorizes it. A plan that requires a submission without naming a
+ // private message to send asks for it too, but a task that started on
+ // another site has no LinkedIn workflow yet. Its post is held to what a
+ // LinkedIn task's post is: the live publish-post job is bound first, so
+ // the post's stable URL and content are recorded and verified, and the
+ // click waits for the next turn under that job.
const planAuthorizesPublication = !!guard && guard.requiresSubmission === true
&& guard.requiresStateChange === true && !target;
- if (!linkedInPublicPost || publishWorkflowAuthorized || planAuthorizesPublication) return null;
+ const otherWorkflow = !!guard?.siteWorkflow?.job;
+ if (planAuthorizesPublication && !otherWorkflow) {
+ if (await this._adoptLiveLinkedInPublishWorkflow(tabId, resolvedPageUrl)) {
+ return {
+ success: false,
+ blocked: true,
+ noDispatch: true,
+ dispatched: false,
+ retryable: true,
+ workflowRearmed: true,
+ workflowJob: 'publish-post',
+ messageRecipientGuard: true,
+ reasonCode: 'publish_workflow_adopted',
+ error: 'Nothing was posted yet: this post now follows the LinkedIn publish workflow, so it can be verified once it is published. Read the composer again, check the exact text, then click Post.',
+ };
+ }
+ // With site adapters off no workflow can be bound, as on any other
+ // site; the normal submission gates still apply to the post.
+ if (!this.useSiteAdapters) return null;
+ }
return {
success: false,
blocked: true,
@@ -25823,7 +25875,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
reasonCode: 'public_post_not_authorized',
error: target
? 'LinkedIn Post blocked because this task authorizes a private message, not a public post.'
- : 'LinkedIn Post blocked because this task does not ask to publish anything, so nothing was posted. Do not post; report what is ready instead.',
+ : !planAuthorizesPublication
+ ? 'LinkedIn Post blocked because this task does not ask to publish anything, so nothing was posted. Do not post; report what is ready instead.'
+ : otherWorkflow
+ ? 'LinkedIn Post blocked because this run is set up for a different task, not a LinkedIn post, so nothing was posted. Do not post; report what is ready instead.'
+ : 'LinkedIn Post blocked because the LinkedIn publish workflow could not be bound, so nothing was posted. Do not post; report what is ready instead.',
};
}
// Gmail reply editors can be collapsed when planning begins. Allow only a
diff --git a/test/fixtures/message-recipient-navigation.mjs b/test/fixtures/message-recipient-navigation.mjs
index 59506fda7..18ded13ec 100644
--- a/test/fixtures/message-recipient-navigation.mjs
+++ b/test/fixtures/message-recipient-navigation.mjs
@@ -856,8 +856,29 @@ export function registerMessageRecipientNavigationFixtures({
Function('return (' + source + ')')()(tool, args), { source: AgentClass._submitActionProbe.toString(), tool: name, args: passArgs }),
tool, args);
// The task started on another site: no LinkedIn workflow, and no
- // private message named. Its plan requires the submission.
+ // private message named. Its plan requires the submission. The first
+ // Post binds the live LinkedIn publish-post job, so the post is
+ // recorded and verified as a LinkedIn task's post, and waits for the
+ // next turn. Under that job the post goes through.
+ const resolved = [];
+ agent._ensureWorkflowMetadataRequirements = async (tabId, _opts, _taskText, pageScope) => {
+ resolved.push(pageScope);
+ const state = agent._planExecutionGuards.get(tabId);
+ state.workflowMetadataRequirements = [{ field: 'body', value: 'Announcement' }];
+ state.workflowMetadataRequirementsResolved = true;
+ state.workflowMetadataRequirementsIncomplete = false;
+ };
plan();
+ await composeShareScreen(page);
+ const adopted = await guard('click', { selector: '#publish' });
+ assert.equal(adopted?.reasonCode, 'publish_workflow_adopted', JSON.stringify(adopted));
+ assert.equal(adopted.noDispatch, true);
+ assert.equal(adopted.workflowRearmed, true);
+ const bound = agent._planExecutionGuards.get(1);
+ assert.equal(bound.siteWorkflow?.adapterName, 'linkedin');
+ assert.equal(bound.siteWorkflow?.job?.id, 'publish-post');
+ assert.equal(bound.workflowMetadataRequirementsResolved, true);
+ assert.deepEqual(resolved, [page.url()]);
for (const postLabel of ['Post', 'Gönder']) {
await composeShareScreen(page, { postLabel });
const ref = await page.evaluate(() => window.__wb_ax_ref(document.querySelector('#publish span')));
@@ -871,6 +892,27 @@ export function registerMessageRecipientNavigationFixtures({
assert.equal(submit.publicationControl, true, `${postLabel} ${tool}: the post is a publication`);
}
}
+ assert.equal(resolved.length, 1, 'the job is bound once');
+ // The submission record binds the post's stable URL and content.
+ const binding = agent._workflowSubmitBindingForAttempt(1, page.url(), {}, { isSubmit: true, publicationControl: true });
+ assert.equal(binding?.verificationKind, 'published_resource');
+ assert.equal(binding.adapterName, 'linkedin');
+ assert.deepEqual(binding.metadataRequirements, [{ field: 'body', value: 'Announcement' }]);
+ // A run set up for another task's workflow does not post.
+ plan({ siteWorkflow: agent._resolvePlannerSiteWorkflow('https://github.com/acme/site/edit/main/README.md',
+ { request_kind: 'execute', site_job: 'edit-file-and-commit' }) });
+ assert.equal(agent._planExecutionGuards.get(1).siteWorkflow?.adapterName, 'github');
+ const otherTask = await guard('click', { selector: '#publish' });
+ assert.equal(otherTask?.reasonCode, 'public_post_not_authorized');
+ assert.match(otherTask.error, /set up for a different task/);
+ assert.equal(agent._planExecutionGuards.get(1).siteWorkflow?.adapterName, 'github');
+ // With site adapters off no job can be bound, as on any other site: the
+ // planned post goes through the normal submission gates.
+ plan();
+ agent.useSiteAdapters = false;
+ assert.equal(await guard('click', { selector: '#publish' }), null);
+ assert.equal(agent._planExecutionGuards.get(1).siteWorkflow, null);
+ agent.useSiteAdapters = true;
// The draft's other controls are not sends, and not the post.
await composeShareScreen(page);
for (const selector of ['#emoji', '#audience', '[contenteditable="true"]']) {