Open-source AI browser agent for Chrome and Firefox (monorepo) ðŸ§
JavaScript ai-agentai-agentsai-toolsbrowser-aibrowser-automationbrowser-extensionchrome-aichrome-devtoolschrome-extensionchrome-extensionsfirefox-addonfirefox-addonsfirefox-extensionfirefox-extensionsgemmagemma4minimaxoffline-aioffline-llmqwen
fix(social-publish): untargeted alt text scoped to images
Barack Sokulluc7d97b282751
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 9597d6e97..e8f47cf0b 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -4617,6 +4617,17 @@ export class Agent extends LoopDetector {requirement?.attachment ?? requirement?.target ?? requirement?.filename,);if (target && record?.uploadNameBindingAmbiguous === true) return false;+ // An unqualified alt-text value describes images: the completion probe+ // records videos with an empty alt or an unrelated aria-label, so videos+ // must not fail an image alt-text contract they never carried.+ const isImageAttachmentForAlt = (attachment) => {+ if (!attachment || typeof attachment !== 'object') return false;+ const type = String(attachment.type || attachment.kind || '').toLowerCase();+ if (type === 'image' || type === 'photo') return true;+ if (type === 'video' || type === 'animated_gif' || type === 'gif') return false;+ const src = String(attachment.src || attachment.url || '');+ return !/\.(?:mp4|mov|webm|mkv|gif)(?:[?#]|$)/i.test(src);+ };const relevantAttachments = target? attachments.filter((attachment) => {if (!attachment || typeof attachment !== 'object') return false;@@ -4630,7 +4641,7 @@ export class Agent extends LoopDetector {});return targetNames.some(expected => candidates.some(candidate => candidate === expected));})- : attachments;+ : attachments.filter(isImageAttachmentForAlt);return relevantAttachments.length > 0 && relevantAttachments.every(attachment => (attachment && typeof attachment === 'object'&& this._workflowMetadataValue(attachment.alt) === wantdiff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex 6d418f33f..3b7fdfa2a 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -4332,6 +4332,17 @@ export class Agent extends LoopDetector {requirement?.attachment ?? requirement?.target ?? requirement?.filename,);if (target && record?.uploadNameBindingAmbiguous === true) return false;+ // An unqualified alt-text value describes images: the completion probe+ // records videos with an empty alt or an unrelated aria-label, so videos+ // must not fail an image alt-text contract they never carried.+ const isImageAttachmentForAlt = (attachment) => {+ if (!attachment || typeof attachment !== 'object') return false;+ const type = String(attachment.type || attachment.kind || '').toLowerCase();+ if (type === 'image' || type === 'photo') return true;+ if (type === 'video' || type === 'animated_gif' || type === 'gif') return false;+ const src = String(attachment.src || attachment.url || '');+ return !/\.(?:mp4|mov|webm|mkv|gif)(?:[?#]|$)/i.test(src);+ };const relevantAttachments = target? attachments.filter((attachment) => {if (!attachment || typeof attachment !== 'object') return false;@@ -4345,7 +4356,7 @@ export class Agent extends LoopDetector {});return targetNames.some(expected => candidates.some(candidate => candidate === expected));})- : attachments;+ : attachments.filter(isImageAttachmentForAlt);return relevantAttachments.length > 0 && relevantAttachments.every(attachment => (attachment && typeof attachment === 'object'&& this._workflowMetadataValue(attachment.alt) === wantdiff --git a/test/run.js b/test/run.jsindex 3782783fc..073022adf 100644--- a/test/run.js+++ b/test/run.js@@ -91739,6 +91739,15 @@ test('X and Bluesky same-route publication accepts only one new permalink with t],},), false, AgentClass.name + ': one matching alt text hid a mismatched attachment');+ assert.equal(agent._workflowSocialPublishedAltTextObserved(+ { value: 'Diagram' },+ {+ attachments: [+ { type: 'image', src: 'https://example.test/a.png', alt: 'Diagram' },+ { type: 'video', src: 'https://example.test/b.mp4', alt: '' },+ ],+ },+ ), true, AgentClass.name + ': an image alt-text contract was failed by a video without alt text');assert.equal(agent._workflowPublishedResourcePayloadMatch({