Skip to content

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

Accept single-page-app publish evidence and stop leaving a file chooser open

Emre Sokulluf28caa79835d
diff --git a/src/chrome/src/agent/adapters.js b/src/chrome/src/agent/adapters.js
index 215321d3f..b4a153d26 100644
--- a/src/chrome/src/agent/adapters.js
+++ b/src/chrome/src/agent/adapters.js
@@ -16232,6 +16232,37 @@ const ADAPTERS = [
- In Messaging, after filling the composer, the reliable send path is usually Enter. If the composer footer says "Press Enter to Send" or the send-options popover shows "Press Enter to Send", call press_keys({key:"Enter"}) from the composer. Do NOT keep scrolling to find a Send button that is already visible/implicit.
- The three-dot / send-options control near the composer opens send preferences ("Press Enter to Send" vs "Click Send"); it is not the Send action. If you opened that popover by mistake, choose/keep "Press Enter to Send", close it if needed, then press Enter to send the focused composer.
- Search has filters (People, Posts, Jobs, Companies) as tabs at the top.`,
+ },
+ {
+ name: 'bluesky',
+ category: 'general',
+ revision: 1,
+ regions: ['global'],
+ jobs: ['publish-post'],
+ workflow: {
+ schema: ADAPTER_WORKFLOW_SCHEMA,
+ jobs: {
+ 'publish-post': {
+ description: 'Prepare, publish, and verify a Bluesky post.',
+ template: 'publish',
+ stateChange: true,
+ requiresSubmission: true,
+ requiresLedger: false,
+ stages: ['access_gate', 'fill', 'review', 'commit', 'verify', 'deliver'],
+ successEvidence: ['The reviewed post appears under the intended handle at a stable /profile/<handle>/post/<id> URL.'],
+ partialEvidence: ['The verified composer text, attached media, and exact account, validation, or publication blocker are reported.'],
+ },
+ },
+ },
+ matches: (url) => /^https?:\/\/(www\.)?bsky\.app\//.test(url),
+ notes: `
+- The composer opens from "Compose new post" (also the "New Post" button on wider layouts) and renders as a dialog over the current feed; the URL does not change while it is open.
+- The post body is a contenteditable rich-text editor, not a textarea. Use set_field / type_ax against the composer textbox ref rather than clicking into it by coordinates.
+- Images attach through a hidden <input type=file> behind "Add media to post" / "Add images". Do NOT click that control to open an OS file dialog β€” call upload_file with the file input's selector and the downloadId or absolute path, which attaches the file without any dialog.
+- Bluesky enforces a 300-character graphene limit and shows a live counter; a post over the limit leaves "Post" disabled rather than reporting an error.
+- Alt text is a separate per-image control. Add it only when the user asked for it.
+- "Post" (labelled "Publish post") commits. There is no <form> submit: the composer closes and the new post is inserted into the feed via XHR, so a closed composer alone is not proof.
+- Report publication only after the post is reachable at its own /profile/<handle>/post/<id> URL under the intended handle, with the requested text and any attached image visible there.`,
},
{
name: 'reddit',
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 66bda5e3a..d964449df 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -1642,6 +1642,14 @@ export class Agent extends LoopDetector {
return null;
}
+ _sameUrlOrigin(a, b) {
+ try {
+ return new URL(String(a || '')).origin === new URL(String(b || '')).origin;
+ } catch (_) {
+ return false;
+ }
+ }
+
_completionSubmissionEvidence(tabId, pageState, pageUrl = '') {
if (!pageState) return { verifiedFinalSubmit: false, liveSignals: [], relevantForms: 0 };
const relevantForms = Number(pageState.relevantFormCount || 0);
@@ -1649,17 +1657,36 @@ export class Agent extends LoopDetector {
? pageState.successMessages.filter(text => this._completionTextSignalsSuccess(text, { allowBare: true }))
: [];
const submit = this._completionSubmitStates.get(tabId);
- const currentDocumentMatchesSubmit = !!(
- submit?.currentUrl
- && this._normalizeUrl(pageUrl || pageState.url || '') === this._normalizeUrl(submit.currentUrl)
+ const observedUrl = pageUrl || pageState.url || '';
+ const normalizedObserved = this._normalizeUrl(observedUrl);
+ const normalizedOriginating = this._normalizeUrl(submit?.originatingUrl || '');
+ // pageState comes from a live read of the document performed for this very
+ // check, so the probe is itself an observation of the page after the
+ // submit. Single-page apps confirm a publish by navigating to the new
+ // resource, and the tools that navigate are not in the observation set, so
+ // insisting on an earlier read made the verification step the reason the
+ // evidence was rejected.
+ const observedAfterSubmit = !!submit
+ && (submit.observedAfterSubmit === true || !!normalizedObserved);
+ const documentChanged = !!submit && (
+ submit.documentChanged === true
+ || (!!normalizedOriginating && !!normalizedObserved && normalizedOriginating !== normalizedObserved)
+ );
+ // What this needs to establish is that the page being reported belongs to
+ // the site that was submitted to, so another site's submit cannot stand in
+ // for this one. Demanding the exact document the last read saw punished
+ // the very navigation the completion guard asks for.
+ const currentDocumentMatchesSubmit = !!submit && (
+ (!!submit.currentUrl && this._normalizeUrl(submit.currentUrl) === normalizedObserved)
+ || this._sameUrlOrigin(observedUrl, submit.originatingUrl || submit.currentUrl || '')
);
const observedSuccessSignal = !!submit?.completionSignalObserved || liveSignals.length > 0;
const verifiedSubmit = !!(
submit?.dispatched
- && submit.observedAfterSubmit
+ && observedAfterSubmit
&& !submit.formValidationFailed
&& currentDocumentMatchesSubmit
- && (submit.documentChanged || observedSuccessSignal)
+ && (documentChanged || observedSuccessSignal)
);
return {
submit,
@@ -2253,6 +2280,13 @@ export class Agent extends LoopDetector {
) {
return `douyin:${host}${path}`;
}
+ if (
+ siteWorkflow?.adapterName === 'bluesky'
+ && host === 'bsky.app'
+ && /^\/profile\/[^/]+\/post\/[^/]+$/i.test(path)
+ ) {
+ return `bluesky:${host}${path}`;
+ }
return '';
}
@@ -22476,7 +22510,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
: missingRequiredDownload
? '[PLAN EXECUTION BLOCK: This task requires a file to be downloaded before it can finish successfully. Finding a URL, link, button, or media source is only read evidence. Use an authorized tool call with the DOWNLOAD capability and verify that it returned successful download evidence. If permission is denied or no file can be saved, call done with outcome partial or failed and explain the limitation; do not claim the file was downloaded.]'
: missingRequiredSubmission
- ? `[PLAN EXECUTION BLOCK: The selected ${state.siteWorkflow?.job?.id || 'workflow'} job requires terminal evidence for its own submit/send/publish/commit contract. Filling fields, another site's submit, or an unrelated success signal is not completion. Dispatch the intended action and observe the job-specific terminal state (for example recipient-bound sent state, saved/published resource, form confirmation, or paid/ticket-issued transaction) before calling done again. If that cannot be verified, use outcome partial or failed and report the exact blocker.]`
+ ? (state.siteWorkflow?.job?.id
+ ? `[PLAN EXECUTION BLOCK: The selected ${state.siteWorkflow.job.id} job requires terminal evidence for its own submit/send/publish/commit contract. Filling fields, another site's submit, or an unrelated success signal is not completion. Dispatch the intended action and observe the job-specific terminal state (for example recipient-bound sent state, saved/published resource, form confirmation, or paid/ticket-issued transaction) before calling done again. If that cannot be verified, use outcome partial or failed and report the exact blocker.]`
+ // No site workflow was selected, so there is no job contract to
+ // point at. Naming one sent the model looking for the terminal
+ // state of something that does not exist.
+ : '[PLAN EXECUTION BLOCK: This task requires a submit/send/publish/commit action, and the page state read at completion does not yet show it took effect. Read the page that resulted from the action β€” the published item, the confirmation, or the changed state β€” in the same browser tab, then call done from there. If the action cannot be confirmed, use outcome partial or failed and report the exact blocker.]')
: forbiddenSubmission
? `[PLAN EXECUTION BLOCK: The selected ${state.siteWorkflow?.job?.id || 'workflow'} job prepares the form and leaves it unsubmitted, but a submit action was dispatched. Do not submit again or try to undo it by submitting anything else. Call done with outcome partial or failed, state plainly that the form was submitted without authorization, and report what the page shows now.]`
: missingJobEvidence
@@ -27348,7 +27387,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
.map(link => {
try { return new URL(link.getAttribute('href') || link.href || '', location.href).href; } catch { return ''; }
})
- .filter(url => /linkedin\\.com\\/(?:feed\\/update|posts)\\/|github\\.com\\/[^/]+\\/[^/]+\\/releases\\/tag\\/|douyin\\.com\\/video\\/\\d+/i.test(url))
+ .filter(url => /linkedin\\.com\\/(?:feed\\/update|posts)\\/|github\\.com\\/[^/]+\\/[^/]+\\/releases\\/tag\\/|douyin\\.com\\/video\\/\\d+|bsky\\.app\\/profile\\/[^/]+\\/post\\//i.test(url))
.slice(0, 200);
return {
openDialogCount: dialogs.length,
diff --git a/src/chrome/src/content/content.js b/src/chrome/src/content/content.js
index b5c088141..1c0bf329d 100644
--- a/src/chrome/src/content/content.js
+++ b/src/chrome/src/content/content.js
@@ -1281,11 +1281,18 @@
if (!state.settled) return { success: true, settled: false, filePickerBlocked: false };
if (state.cleanupTimer) clearTimeout(state.cleanupTimer);
document.removeEventListener('click', state.guard, true);
- // If nothing was observed, stop content-side observation but leave the
- // page-world programmatic click/showPicker guard active until its own
- // short TTL. This suppresses longer debounces without blocking the tool
- // response or intercepting a user's direct native input click.
- state.cleanupPageShowPickerGuard?.(!!state.blocked);
+ // Stop content-side observation, but leave the page-world programmatic
+ // click/showPicker guard active until its own short TTL. This suppresses
+ // longer debounces without blocking the tool response or intercepting a
+ // user's direct native input click.
+ //
+ // This has to hold most of all when something WAS blocked. An app that
+ // routes an upload affordance through a file input often retries on a
+ // timer, and disarming here on the strength of the first interception left
+ // that retry unguarded β€” it opened a real OS chooser that nothing can
+ // close, and it stayed on screen through the rest of the run while
+ // upload_file attached the file directly.
+ state.cleanupPageShowPickerGuard?.(false);
_filePickerGuardStates.delete(guardId);
if (state.blocked) {
return { ...filePickerBlockedResponse(state.blocked), settled: true };
diff --git a/src/firefox/src/agent/adapters.js b/src/firefox/src/agent/adapters.js
index af3212d76..3514fa3ae 100644
--- a/src/firefox/src/agent/adapters.js
+++ b/src/firefox/src/agent/adapters.js
@@ -16231,6 +16231,37 @@ const ADAPTERS = [
- In Messaging, after filling the composer, the reliable send path is usually Enter. If the composer footer says "Press Enter to Send" or the send-options popover shows "Press Enter to Send", call press_keys({key:"Enter"}) from the composer. Do NOT keep scrolling to find a Send button that is already visible/implicit.
- The three-dot / send-options control near the composer opens send preferences ("Press Enter to Send" vs "Click Send"); it is not the Send action. If you opened that popover by mistake, choose/keep "Press Enter to Send", close it if needed, then press Enter to send the focused composer.
- Search has filters (People, Posts, Jobs, Companies) as tabs at the top.`,
+ },
+ {
+ name: 'bluesky',
+ category: 'general',
+ revision: 1,
+ regions: ['global'],
+ jobs: ['publish-post'],
+ workflow: {
+ schema: ADAPTER_WORKFLOW_SCHEMA,
+ jobs: {
+ 'publish-post': {
+ description: 'Prepare, publish, and verify a Bluesky post.',
+ template: 'publish',
+ stateChange: true,
+ requiresSubmission: true,
+ requiresLedger: false,
+ stages: ['access_gate', 'fill', 'review', 'commit', 'verify', 'deliver'],
+ successEvidence: ['The reviewed post appears under the intended handle at a stable /profile/<handle>/post/<id> URL.'],
+ partialEvidence: ['The verified composer text, attached media, and exact account, validation, or publication blocker are reported.'],
+ },
+ },
+ },
+ matches: (url) => /^https?:\/\/(www\.)?bsky\.app\//.test(url),
+ notes: `
+- The composer opens from "Compose new post" (also the "New Post" button on wider layouts) and renders as a dialog over the current feed; the URL does not change while it is open.
+- The post body is a contenteditable rich-text editor, not a textarea. Use set_field / type_ax against the composer textbox ref rather than clicking into it by coordinates.
+- Images attach through a hidden <input type=file> behind "Add media to post" / "Add images". Do NOT click that control to open an OS file dialog β€” call upload_file with the file input's selector and the downloadId or absolute path, which attaches the file without any dialog.
+- Bluesky enforces a 300-character graphene limit and shows a live counter; a post over the limit leaves "Post" disabled rather than reporting an error.
+- Alt text is a separate per-image control. Add it only when the user asked for it.
+- "Post" (labelled "Publish post") commits. There is no <form> submit: the composer closes and the new post is inserted into the feed via XHR, so a closed composer alone is not proof.
+- Report publication only after the post is reachable at its own /profile/<handle>/post/<id> URL under the intended handle, with the requested text and any attached image visible there.`,
},
{
name: 'reddit',
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 65373d6e9..0c4496373 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -1356,6 +1356,14 @@ export class Agent extends LoopDetector {
return null;
}
+ _sameUrlOrigin(a, b) {
+ try {
+ return new URL(String(a || '')).origin === new URL(String(b || '')).origin;
+ } catch (_) {
+ return false;
+ }
+ }
+
_completionSubmissionEvidence(tabId, pageState, pageUrl = '') {
if (!pageState) return { verifiedFinalSubmit: false, liveSignals: [], relevantForms: 0 };
const relevantForms = Number(pageState.relevantFormCount || 0);
@@ -1363,17 +1371,36 @@ export class Agent extends LoopDetector {
? pageState.successMessages.filter(text => this._completionTextSignalsSuccess(text, { allowBare: true }))
: [];
const submit = this._completionSubmitStates.get(tabId);
- const currentDocumentMatchesSubmit = !!(
- submit?.currentUrl
- && this._normalizeUrl(pageUrl || pageState.url || '') === this._normalizeUrl(submit.currentUrl)
+ const observedUrl = pageUrl || pageState.url || '';
+ const normalizedObserved = this._normalizeUrl(observedUrl);
+ const normalizedOriginating = this._normalizeUrl(submit?.originatingUrl || '');
+ // pageState comes from a live read of the document performed for this very
+ // check, so the probe is itself an observation of the page after the
+ // submit. Single-page apps confirm a publish by navigating to the new
+ // resource, and the tools that navigate are not in the observation set, so
+ // insisting on an earlier read made the verification step the reason the
+ // evidence was rejected.
+ const observedAfterSubmit = !!submit
+ && (submit.observedAfterSubmit === true || !!normalizedObserved);
+ const documentChanged = !!submit && (
+ submit.documentChanged === true
+ || (!!normalizedOriginating && !!normalizedObserved && normalizedOriginating !== normalizedObserved)
+ );
+ // What this needs to establish is that the page being reported belongs to
+ // the site that was submitted to, so another site's submit cannot stand in
+ // for this one. Demanding the exact document the last read saw punished
+ // the very navigation the completion guard asks for.
+ const currentDocumentMatchesSubmit = !!submit && (
+ (!!submit.currentUrl && this._normalizeUrl(submit.currentUrl) === normalizedObserved)
+ || this._sameUrlOrigin(observedUrl, submit.originatingUrl || submit.currentUrl || '')
);
const observedSuccessSignal = !!submit?.completionSignalObserved || liveSignals.length > 0;
const verifiedSubmit = !!(
submit?.dispatched
- && submit.observedAfterSubmit
+ && observedAfterSubmit
&& !submit.formValidationFailed
&& currentDocumentMatchesSubmit
- && (submit.documentChanged || observedSuccessSignal)
+ && (documentChanged || observedSuccessSignal)
);
return {
submit,
@@ -1967,6 +1994,13 @@ export class Agent extends LoopDetector {
) {
return `douyin:${host}${path}`;
}
+ if (
+ siteWorkflow?.adapterName === 'bluesky'
+ && host === 'bsky.app'
+ && /^\/profile\/[^/]+\/post\/[^/]+$/i.test(path)
+ ) {
+ return `bluesky:${host}${path}`;
+ }
return '';
}
@@ -20079,7 +20113,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
: missingRequiredDownload
? '[PLAN EXECUTION BLOCK: This task requires a file to be downloaded before it can finish successfully. Finding a URL, link, button, or media source is only read evidence. Use an authorized tool call with the DOWNLOAD capability and verify that it returned successful download evidence. If permission is denied or no file can be saved, call done with outcome partial or failed and explain the limitation; do not claim the file was downloaded.]'
: missingRequiredSubmission
- ? `[PLAN EXECUTION BLOCK: The selected ${state.siteWorkflow?.job?.id || 'workflow'} job requires terminal evidence for its own submit/send/publish/commit contract. Filling fields, another site's submit, or an unrelated success signal is not completion. Dispatch the intended action and observe the job-specific terminal state (for example recipient-bound sent state, saved/published resource, form confirmation, or paid/ticket-issued transaction) before calling done again. If that cannot be verified, use outcome partial or failed and report the exact blocker.]`
+ ? (state.siteWorkflow?.job?.id
+ ? `[PLAN EXECUTION BLOCK: The selected ${state.siteWorkflow.job.id} job requires terminal evidence for its own submit/send/publish/commit contract. Filling fields, another site's submit, or an unrelated success signal is not completion. Dispatch the intended action and observe the job-specific terminal state (for example recipient-bound sent state, saved/published resource, form confirmation, or paid/ticket-issued transaction) before calling done again. If that cannot be verified, use outcome partial or failed and report the exact blocker.]`
+ // No site workflow was selected, so there is no job contract to
+ // point at. Naming one sent the model looking for the terminal
+ // state of something that does not exist.
+ : '[PLAN EXECUTION BLOCK: This task requires a submit/send/publish/commit action, and the page state read at completion does not yet show it took effect. Read the page that resulted from the action β€” the published item, the confirmation, or the changed state β€” in the same browser tab, then call done from there. If the action cannot be confirmed, use outcome partial or failed and report the exact blocker.]')
: forbiddenSubmission
? `[PLAN EXECUTION BLOCK: The selected ${state.siteWorkflow?.job?.id || 'workflow'} job prepares the form and leaves it unsubmitted, but a submit action was dispatched. Do not submit again or try to undo it by submitting anything else. Call done with outcome partial or failed, state plainly that the form was submitted without authorization, and report what the page shows now.]`
: missingJobEvidence
@@ -23821,7 +23860,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
.map(link => {
try { return new URL(link.getAttribute('href') || link.href || '', location.href).href; } catch { return ''; }
})
- .filter(url => /linkedin\\.com\\/(?:feed\\/update|posts)\\/|github\\.com\\/[^/]+\\/[^/]+\\/releases\\/tag\\/|douyin\\.com\\/video\\/\\d+/i.test(url))
+ .filter(url => /linkedin\\.com\\/(?:feed\\/update|posts)\\/|github\\.com\\/[^/]+\\/[^/]+\\/releases\\/tag\\/|douyin\\.com\\/video\\/\\d+|bsky\\.app\\/profile\\/[^/]+\\/post\\//i.test(url))
.slice(0, 200);
return {
url: location.href,
diff --git a/src/firefox/src/content/content.js b/src/firefox/src/content/content.js
index 632b343cc..cb410a618 100644
--- a/src/firefox/src/content/content.js
+++ b/src/firefox/src/content/content.js
@@ -1505,11 +1505,18 @@
if (!state.settled) return { success: true, settled: false, filePickerBlocked: false };
if (state.cleanupTimer) clearTimeout(state.cleanupTimer);
document.removeEventListener('click', state.guard, true);
- // If nothing was observed, stop content-side observation but leave the
- // page-world programmatic click/showPicker guard active until its own
- // short TTL. This suppresses longer debounces without blocking the tool
- // response or intercepting a user's direct native input click.
- state.cleanupPageShowPickerGuard?.(!!state.blocked);
+ // Stop content-side observation, but leave the page-world programmatic
+ // click/showPicker guard active until its own short TTL. This suppresses
+ // longer debounces without blocking the tool response or intercepting a
+ // user's direct native input click.
+ //
+ // This has to hold most of all when something WAS blocked. An app that
+ // routes an upload affordance through a file input often retries on a
+ // timer, and disarming here on the strength of the first interception left
+ // that retry unguarded β€” it opened a real OS chooser that nothing can
+ // close, and it stayed on screen through the rest of the run while
+ // upload_file attached the file directly.
+ state.cleanupPageShowPickerGuard?.(false);
_filePickerGuardStates.delete(guardId);
if (state.blocked) {
return { ...filePickerBlockedResponse(state.blocked), settled: true };
diff --git a/test/run.js b/test/run.js
index a99a621d9..3f760c1e6 100644
--- a/test/run.js
+++ b/test/run.js
@@ -7901,6 +7901,7 @@ test('12306 exposes a validated regional workflow profile with browser parity',
'microsoft-forms',
'gmail',
'linkedin',
+ 'bluesky',
'youtube',
'railway-12306',
'douyin',
@@ -7987,6 +7988,7 @@ test('report-driven workflow adapters route exact app-owned jobs with browser pa
['https://forms.cloud.microsoft/pages/responsepage.aspx?id=x', 'microsoft-forms', 'submit-form'],
['https://mail.google.com/mail/u/0/#inbox/abc', 'gmail', 'read-complete-thread'],
['https://www.linkedin.com/feed/', 'linkedin', 'publish-post'],
+ ['https://bsky.app/', 'bluesky', 'publish-post'],
['https://studio.youtube.com/video/abc/edit', 'youtube', 'update-metadata'],
['https://www.douyin.com/video/1', 'douyin', 'collect-comments'],
['https://www.naukrigulf.com/job/example', 'naukrigulf', 'submit-application'],
@@ -84828,6 +84830,112 @@ test('YouTube metadata success requires exact app-classified post-save readback'
}
});
+test('single-page app publish evidence survives the verification navigation', () => {
+ for (const AgentClass of [AgentCh, AgentFx]) {
+ const agent = new AgentClass({ getVisionProvider: async () => null });
+ const tabId = 8801;
+ const pageState = { relevantFormCount: 0, successMessages: [] };
+ const postUrl = 'https://bsky.app/profile/webbrain-one.bsky.social/post/3mutnbiq6d22s';
+ const publishedSubmit = (overrides = {}) => ({
+ originatingUrl: 'https://bsky.app/',
+ currentUrl: 'https://bsky.app/profile/webbrain-one.bsky.social',
+ submitLike: true,
+ dispatched: true,
+ documentChanged: true,
+ formValidationFailed: false,
+ completionSignalObserved: false,
+ observedAfterSubmit: true,
+ ...overrides,
+ });
+
+ // The completion guard asks the agent to go and observe the resulting
+ // state. Doing exactly that lands done on a document the post-submit reads
+ // never saw, which used to invalidate the evidence the guard demanded.
+ agent._completionSubmitStates.set(tabId, publishedSubmit());
+ assert.equal(
+ agent._completionSubmissionEvidence(tabId, pageState, postUrl).verifiedFinalSubmit,
+ true,
+ `${AgentClass.name}: navigating to the published resource invalidated its own evidence`,
+ );
+
+ // done reads the live document, so that read is itself the observation.
+ agent._completionSubmitStates.set(tabId, publishedSubmit({
+ currentUrl: 'https://bsky.app/',
+ observedAfterSubmit: false,
+ }));
+ assert.equal(
+ agent._completionSubmissionEvidence(tabId, pageState, postUrl).verifiedFinalSubmit,
+ true,
+ `${AgentClass.name}: the completion probe was not counted as an observation`,
+ );
+
+ // Still no completion when nothing actually changed: a dispatched click on
+ // a page that stayed put and produced no success signal proves nothing.
+ agent._completionSubmitStates.set(tabId, publishedSubmit({
+ currentUrl: 'https://bsky.app/',
+ documentChanged: false,
+ observedAfterSubmit: false,
+ }));
+ assert.equal(
+ agent._completionSubmissionEvidence(tabId, pageState, 'https://bsky.app/').verifiedFinalSubmit,
+ false,
+ `${AgentClass.name}: an unchanged page after a submit-like click counted as completion`,
+ );
+
+ // Another site's submit must never stand in for this one.
+ agent._completionSubmitStates.set(tabId, publishedSubmit({
+ originatingUrl: 'https://example.com/compose',
+ currentUrl: 'https://example.com/compose',
+ }));
+ assert.equal(
+ agent._completionSubmissionEvidence(tabId, pageState, postUrl).verifiedFinalSubmit,
+ false,
+ `${AgentClass.name}: a submit on a different origin satisfied this task`,
+ );
+
+ // Bluesky posts get a stable published-resource identity; a profile or
+ // feed URL is not one.
+ assert.equal(
+ agent._workflowPublishedResourceIdentity({ adapterName: 'bluesky' }, postUrl),
+ 'bluesky:bsky.app/profile/webbrain-one.bsky.social/post/3mutnbiq6d22s',
+ `${AgentClass.name}: a published Bluesky post produced no resource identity`,
+ );
+ for (const notAPost of [
+ 'https://bsky.app/profile/webbrain-one.bsky.social',
+ 'https://bsky.app/',
+ 'https://example.com/profile/a/post/b',
+ ]) {
+ assert.equal(
+ agent._workflowPublishedResourceIdentity({ adapterName: 'bluesky' }, notAPost),
+ '',
+ `${AgentClass.name}: ${notAPost} was accepted as a published post`,
+ );
+ }
+ }
+});
+
+test('a submit block names a workflow job only when one was selected', () => {
+ for (const relPath of [
+ 'src/chrome/src/agent/agent.js',
+ 'src/firefox/src/agent/agent.js',
+ ]) {
+ const source = fs.readFileSync(path.join(ROOT, relPath), 'utf8');
+ // With no site workflow selected there is no job contract to point at.
+ // The old `|| 'workflow'` fallback sent the model looking for the terminal
+ // state of a job that never existed, which it could not produce.
+ assert.doesNotMatch(
+ source,
+ /The selected \$\{state\.siteWorkflow\?\.job\?\.id \|\| 'workflow'\} job requires terminal evidence/,
+ `${relPath}: the submit block still invents a workflow job when none was selected`,
+ );
+ assert.match(
+ source,
+ /This task requires a submit\/send\/publish\/commit action, and the page state read at completion does not yet show it took effect\./,
+ `${relPath}: missing the job-free submit recovery instruction`,
+ );
+ }
+});
+
test('adapter workflow execution policy is bounded and mirrored', () => {
const selected = resolveAdapterWorkflowJob(
'https://forms.cloud.microsoft/pages/responsepage.aspx?id=x',
@@ -92646,7 +92754,12 @@ test('Chrome click paths suppress native file choosers and redirect to upload_fi
assert.match(source, /const installPageShowPickerGuard = \(\) =>/, `${relPath}: missing page-world showPicker bridge handshake`);
assert.match(source, /webbrain:file-picker-guard-arm/, `${relPath}: missing page-world showPicker arm event`);
assert.match(source, /webbrain:file-picker-guard-blocked/, `${relPath}: missing page-world blocked result event`);
- assert.match(source, /cleanupPageShowPickerGuard\?\.\(!!state\.blocked\)/, `${relPath}: delayed programmatic guard should survive an empty consume`);
+ // The page-world guard must outlive the consume in BOTH directions. An app
+ // that retries its upload affordance on a timer would otherwise open a real
+ // OS chooser on the retry β€” one nothing can close, which then sits on
+ // screen for the rest of the run while upload_file attaches the file.
+ assert.match(source, /cleanupPageShowPickerGuard\?\.\(false\)/, `${relPath}: delayed programmatic guard should survive a consume whether or not it intercepted`);
+ assert.doesNotMatch(source, /cleanupPageShowPickerGuard\?\.\(!!state\.blocked\)/, `${relPath}: an interception must not disarm the guard that stops the retry`);
assert.match(source, /clickWithoutNativeFilePicker\(\(\) => el\.click\(\)\)/, `${relPath}: synthetic clicks should use the chooser guard`);
assert.match(source, /_filePickerGuardId:\s*filePickerGuard\.guardId/, `${relPath}: click response should return without waiting on the unloading document`);
assert.match(source, /'consume_file_picker_guard':\s*\(\) => consumeFilePickerGuard/, `${relPath}: missing deferred guard result handshake`);