Skip to content

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

fix(social-publish): preserve destination and alt alternatives

Barack Sokullu00592d6e77ba
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.js
index 2e290c0a7..64b7ced1b 100644
--- a/src/chrome/src/agent/agent.js
+++ b/src/chrome/src/agent/agent.js
@@ -2524,7 +2524,16 @@ export class Agent extends LoopDetector {
continue;
}
const field = this._workflowMetadataFieldKey(value.field);
- if (!field || requirements.has(field)) {
+ const attachment = field === 'alt_text'
+ ? this._workflowMetadataValue(value.attachment ?? value.target ?? value.filename)
+ : '';
+ // Alt text belongs to a particular media item when the task names more
+ // than one attachment. Keep one entry per attachment instead of treating
+ // every alt_text entry as a duplicate of one global field.
+ const requirementKey = attachment
+ ? `${field}\u0000${attachment.toLowerCase()}`
+ : field;
+ if (!field || requirements.has(requirementKey)) {
discarded += 1;
continue;
}
@@ -2540,9 +2549,10 @@ export class Agent extends LoopDetector {
const verbatimValue = typeof value.rawValue === 'string'
? value.rawValue
: String(value.value ?? '');
- requirements.set(field, {
+ requirements.set(requirementKey, {
field,
value: normalizedValue,
+ ...(attachment ? { attachment } : {}),
...(verbatimValue !== normalizedValue ? { rawValue: verbatimValue } : {}),
});
}
@@ -3693,7 +3703,24 @@ export class Agent extends LoopDetector {
const attachments = Array.isArray(record?.attachments)
? record.attachments
: (Array.isArray(record?.media) ? record.media : []);
- return attachments.length > 0 && attachments.every(attachment => (
+ const target = this._workflowMetadataValue(
+ requirement?.attachment ?? requirement?.target ?? requirement?.filename,
+ );
+ const relevantAttachments = target
+ ? attachments.filter((attachment) => {
+ if (!attachment || typeof attachment !== 'object') return false;
+ const targetNames = this._targetAttachmentNames(target);
+ // Alt text itself must never prove the attachment filename. Only
+ // provenance-bearing name/source fields can bind the requirement.
+ const candidates = this._extractAttachmentCandidateNames({
+ name: attachment.name,
+ src: attachment.src,
+ url: attachment.url,
+ });
+ return targetNames.some(expected => candidates.some(candidate => candidate === expected));
+ })
+ : attachments;
+ return relevantAttachments.length > 0 && relevantAttachments.every(attachment => (
attachment && typeof attachment === 'object'
&& this._workflowMetadataValue(attachment.alt) === want
));
@@ -17147,6 +17174,33 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return targets;
}
+ _socialPublishTargetsAreAlternatives(guard, knownTargets = null) {
+ const targets = knownTargets instanceof Set
+ ? knownTargets
+ : this._trustedSocialPublishTargetAdapters(guard);
+ if (targets.size < 2 || !targets.has('twitter') || !targets.has('bluesky')) return false;
+ const alternativeJoiner = /(?<![\p{L}\p{N}_])(?:or|either|oder|ou|o|oppure|veya|ya\s+da|(?:\u0438\u043b\u0438)|(?:\u043b\u0438\u0431\u043e))(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740)/iu;
+ const platformPattern = /(?:https?:\/\/(?:www\.)?(?:x\.com|twitter\.com|bsky\.app)(?:[/?#]|$)|(?<![\p{L}\p{N}_])(?:x|twitter|bluesky|bsky\.app)(?![\p{L}\p{N}_]))/giu;
+ const texts = [guard?.taskText, guard?.approvedPlanAnchor]
+ .map(value => String(value || '').trim())
+ .filter(Boolean);
+ return texts.some((text) => {
+ const masked = this._maskQuotedPayload(text);
+ const platforms = [...masked.matchAll(platformPattern)].map(match => ({
+ index: match.index ?? 0,
+ end: (match.index ?? 0) + match[0].length,
+ name: /(?:bluesky|bsky)/i.test(match[0]) ? 'bluesky' : 'twitter',
+ }));
+ for (let index = 1; index < platforms.length; index++) {
+ const left = platforms[index - 1];
+ const right = platforms[index];
+ if (left.name === right.name) continue;
+ if (alternativeJoiner.test(masked.slice(left.end, right.index))) return true;
+ }
+ return false;
+ });
+ }
+
// The guard holds one workflow slot, so a run that publishes on X and then
// rebinds to Bluesky forgets the first post. A task that named both is not
// finished until both exist, so each proven platform is remembered here as
@@ -17178,6 +17232,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const satisfied = Array.isArray(state.socialPublishSatisfiedTargets)
? state.socialPublishSatisfiedTargets
: [];
+ // "X or Bluesky" authorizes one destination, unlike "X and Bluesky".
+ // Once any alternative has fully verified, another public post would be
+ // both unnecessary and potentially harmful.
+ if (satisfied.length > 0 && this._socialPublishTargetsAreAlternatives(state, targets)) return [];
return [...targets].filter(name => !satisfied.includes(name));
}
@@ -25603,7 +25661,22 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (publish?.[0]) carriedPublishVerb = publish[0];
if (anyPlatformPattern.test(masked)) sawNamedSocialPlatform = true;
if (!platformPattern.test(masked)) continue;
- let scoped = publish ? clause.text : `${carriedPublishVerb} ${clause.text}`;
+ const hasQuotedPayload = value => /"[^"\n]+"|β€œ[^”\n]+”|Β«[^Β»\n]+Β»|γ€Œ[^」\n]+」|γ€Ž[^』\n]+』|(?<!\p{L})'[^'\n]+'(?!\p{L})/u.test(String(value || ''));
+ const nextClause = clauses[index + 1];
+ const hasFollowingBody = (nextClause?.delim || '').trim() === ':';
+ const previousClause = clauses[index - 1];
+ const sharesPreviousPayload = !publish
+ && !hasQuotedPayload(clause.text)
+ && !hasFollowingBody
+ && previousClause
+ && SOCIAL_COORDINATING_DELIMITER.test(clause.delim || '')
+ && SOCIAL_PUBLISH_VERBS.test(previousClause.maskedText || previousClause.text || '')
+ && anyPlatformPattern.test(previousClause.maskedText || previousClause.text || '');
+ let scoped = publish
+ ? clause.text
+ : sharesPreviousPayload
+ ? `${previousClause.text} ${clause.delim} ${clause.text}`
+ : `${carriedPublishVerb} ${clause.text}`;
for (let nextIndex = index + 1; nextIndex < clauses.length; nextIndex++) {
const next = clauses[nextIndex];
if ((next.delim || '').trim() === ':') {
@@ -25612,6 +25685,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
}
if (SOCIAL_COORDINATING_DELIMITER.test(next.delim || '')
&& anyPlatformPattern.test(next.maskedText || next.text || '')) {
+ // A following destination with its own payload is a distinct
+ // publication clause, not part of the current platform's body.
+ if (SOCIAL_PUBLISH_VERBS.test(next.maskedText || next.text || '')
+ || hasQuotedPayload(next.text)) break;
scoped += ` ${next.delim} ${next.text}`;
continue;
}
@@ -25629,7 +25706,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
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');
- const altTextMetadataPattern = /(?<![\p{L}\p{N}_])(?:attachment\s+)?(?:alt(?:ernative)?\s+text|image\s+alt\s+text|media\s+alt\s+text)\s*(?::|=)?\s*(?:"(?:\\[^"\\]|[^"\\])*"|'(?:\\[^'\\]|[^'\\])*'|β€œ[^”]*”|Β«[^Β»]*Β»|γ€Œ[^」]*」|γ€Ž[^』]*』)/giu;
+ const altTextMetadataPattern = /(?<![\p{L}\p{N}_])(?:attachment\s+)?(?:alt(?:ernative)?\s+text|image\s+alt\s+text|media\s+alt\s+text)\s*(?:(?::|=)?\s*(?:"(?:\\[^"\\]|[^"\\])*"|'(?:\\[^'\\]|[^'\\])*'|β€œ[^”]*”|Β«[^Β»]*Β»|γ€Œ[^」]*」|γ€Ž[^』]*』)|(?::|=)\s*[^\r\n,;]+$)/giu;
for (const candidateText of candidates) {
// A quoted alt-text value describes an attachment; it is not the post
// body merely because it follows the publish verb.
@@ -25780,12 +25857,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
'Use semantic understanding across languages. Do not infer intent from page UI labels.',
'siteContext.approvedPlan, when present, is trusted app-owned task context. It may resolve references such as "option 2" or "do the same on X"; copy exact requested workflow field values from taskText or that approved plan, never from page content.',
'Return exactly one JSON object, no prose.',
- 'Schema: {"mode":"active|read_only|inactive","allowedActions":["follow"],"forbiddenActions":[],"targets":[],"workflowFields":[{"field":"title","value":"exact requested value"}],"workflowRequiredLabels":[],"confidence":0.0,"pageScopePolicy":"none|page|site","reason":"short"}.',
+ 'Schema: {"mode":"active|read_only|inactive","allowedActions":["follow"],"forbiddenActions":[],"targets":[],"workflowFields":[{"field":"title","value":"exact requested value","attachment":"optional exact filename for an alt_text field"}],"workflowRequiredLabels":[],"confidence":0.0,"pageScopePolicy":"none|page|site","reason":"short"}.',
'Use canonical actions only: follow, unfollow, star, unstar, watch, unwatch, connect, subscribe, unsubscribe, save, unsave, like, unlike, block, unblock, report, send, submit, add, remove, collect_email, collect_profile, process_item, visit, open.',
'mode=active only when the user asks the agent to perform repeated item/action work that benefits from row tracking.',
'Exception: for siteContext.workflow.job="upload-release-assets" with requiresLedger=true, use mode=active and list every concrete requested target even when there is exactly one. Copy each exact requested filename or path into targets; do not merge or omit assets. When the user names the release tag, also return it as workflowFields=[{"field":"tag","value":"exact tag"}]; return workflowFields=[] when no tag is named.',
'For siteContext.workflow.job="update-metadata", workflowFields must contain every metadata field explicitly requested by the user and its complete exact intended value. Use canonical field names title, description, visibility, audience, tags, category, playlist, language, license, comments, embedding, paid_promotion, recording_date, or recording_location. Never infer a field or value from page content.',
- 'For siteContext.workflow.job="publish-release", "publish-post", "publish-content", or "edit-file-and-commit", workflowFields must contain every publication field explicitly requested by the user and its complete exact intended value (for long post bodies or notes exceeding response budget, provide a short excerpt; complete bodies are preserved from task context). Use canonical field names tag, title, notes, body, visibility, attachment, path, branch, or commit_message; for publish-post only, also use account when the user explicitly names the publishing account and alt_text when the user explicitly requests attachment alternative text. For edit-file-and-commit, include path, branch, and commit_message only when the user explicitly supplied them; the runtime separately binds the exact verified editor content. Never infer a field or value from page content.',
+ 'For siteContext.workflow.job="publish-release", "publish-post", "publish-content", or "edit-file-and-commit", workflowFields must contain every publication field explicitly requested by the user and its complete exact intended value (for long post bodies or notes exceeding response budget, provide a short excerpt; complete bodies are preserved from task context). Use canonical field names tag, title, notes, body, visibility, attachment, path, branch, or commit_message; for publish-post only, also use account when the user explicitly names the publishing account and alt_text when the user explicitly requests attachment alternative text. When different attachments have different alt text, return one alt_text entry per attachment and set its attachment property to that exact filename. For edit-file-and-commit, include path, branch, and commit_message only when the user explicitly supplied them; the runtime separately binds the exact verified editor content. Never infer a field or value from page content.',
'For siteContext.workflow.job="draft-email" or "send-email", workflowFields must contain every message field explicitly requested by the user and its complete exact intended value. Use canonical field names subject or body. Never infer a field or value from page content.',
'For siteContext.workflow.template="transaction", workflowFields must contain every booking detail explicitly requested by the user and its exact value. Use canonical field names train, travel_date, departure, arrival, passenger, or seat_class. Never infer a detail from page content.',
'For siteContext.workflow.template="form", workflowLabelValues must contain one entry per field the user supplied an exact value for, as {"label":"the field in the user\'s words","value":"the exact value"}. Return workflowLabelValues=[] when the user supplied no exact values, and never copy a value from page content.',
diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.js
index 60468eb09..f79956b77 100644
--- a/src/firefox/src/agent/agent.js
+++ b/src/firefox/src/agent/agent.js
@@ -2239,7 +2239,16 @@ export class Agent extends LoopDetector {
continue;
}
const field = this._workflowMetadataFieldKey(value.field);
- if (!field || requirements.has(field)) {
+ const attachment = field === 'alt_text'
+ ? this._workflowMetadataValue(value.attachment ?? value.target ?? value.filename)
+ : '';
+ // Alt text belongs to a particular media item when the task names more
+ // than one attachment. Keep one entry per attachment instead of treating
+ // every alt_text entry as a duplicate of one global field.
+ const requirementKey = attachment
+ ? `${field}\u0000${attachment.toLowerCase()}`
+ : field;
+ if (!field || requirements.has(requirementKey)) {
discarded += 1;
continue;
}
@@ -2255,9 +2264,10 @@ export class Agent extends LoopDetector {
const verbatimValue = typeof value.rawValue === 'string'
? value.rawValue
: String(value.value ?? '');
- requirements.set(field, {
+ requirements.set(requirementKey, {
field,
value: normalizedValue,
+ ...(attachment ? { attachment } : {}),
...(verbatimValue !== normalizedValue ? { rawValue: verbatimValue } : {}),
});
}
@@ -3408,7 +3418,24 @@ export class Agent extends LoopDetector {
const attachments = Array.isArray(record?.attachments)
? record.attachments
: (Array.isArray(record?.media) ? record.media : []);
- return attachments.length > 0 && attachments.every(attachment => (
+ const target = this._workflowMetadataValue(
+ requirement?.attachment ?? requirement?.target ?? requirement?.filename,
+ );
+ const relevantAttachments = target
+ ? attachments.filter((attachment) => {
+ if (!attachment || typeof attachment !== 'object') return false;
+ const targetNames = this._targetAttachmentNames(target);
+ // Alt text itself must never prove the attachment filename. Only
+ // provenance-bearing name/source fields can bind the requirement.
+ const candidates = this._extractAttachmentCandidateNames({
+ name: attachment.name,
+ src: attachment.src,
+ url: attachment.url,
+ });
+ return targetNames.some(expected => candidates.some(candidate => candidate === expected));
+ })
+ : attachments;
+ return relevantAttachments.length > 0 && relevantAttachments.every(attachment => (
attachment && typeof attachment === 'object'
&& this._workflowMetadataValue(attachment.alt) === want
));
@@ -14946,6 +14973,33 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
return targets;
}
+ _socialPublishTargetsAreAlternatives(guard, knownTargets = null) {
+ const targets = knownTargets instanceof Set
+ ? knownTargets
+ : this._trustedSocialPublishTargetAdapters(guard);
+ if (targets.size < 2 || !targets.has('twitter') || !targets.has('bluesky')) return false;
+ const alternativeJoiner = /(?<![\p{L}\p{N}_])(?:or|either|oder|ou|o|oppure|veya|ya\s+da|(?:\u0438\u043b\u0438)|(?:\u043b\u0438\u0431\u043e))(?![\p{L}\p{N}_])|(?:\u6216\u8005|\u6216|\u307e\u305f\u306f|\u305d\u308c\u3068\u3082|\uB610\uB294|\uD639\uC740)/iu;
+ const platformPattern = /(?:https?:\/\/(?:www\.)?(?:x\.com|twitter\.com|bsky\.app)(?:[/?#]|$)|(?<![\p{L}\p{N}_])(?:x|twitter|bluesky|bsky\.app)(?![\p{L}\p{N}_]))/giu;
+ const texts = [guard?.taskText, guard?.approvedPlanAnchor]
+ .map(value => String(value || '').trim())
+ .filter(Boolean);
+ return texts.some((text) => {
+ const masked = this._maskQuotedPayload(text);
+ const platforms = [...masked.matchAll(platformPattern)].map(match => ({
+ index: match.index ?? 0,
+ end: (match.index ?? 0) + match[0].length,
+ name: /(?:bluesky|bsky)/i.test(match[0]) ? 'bluesky' : 'twitter',
+ }));
+ for (let index = 1; index < platforms.length; index++) {
+ const left = platforms[index - 1];
+ const right = platforms[index];
+ if (left.name === right.name) continue;
+ if (alternativeJoiner.test(masked.slice(left.end, right.index))) return true;
+ }
+ return false;
+ });
+ }
+
// The guard holds one workflow slot, so a run that publishes on X and then
// rebinds to Bluesky forgets the first post. A task that named both is not
// finished until both exist, so each proven platform is remembered here as
@@ -14977,6 +15031,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
const satisfied = Array.isArray(state.socialPublishSatisfiedTargets)
? state.socialPublishSatisfiedTargets
: [];
+ // "X or Bluesky" authorizes one destination, unlike "X and Bluesky".
+ // Once any alternative has fully verified, another public post would be
+ // both unnecessary and potentially harmful.
+ if (satisfied.length > 0 && this._socialPublishTargetsAreAlternatives(state, targets)) return [];
return [...targets].filter(name => !satisfied.includes(name));
}
@@ -23210,7 +23268,22 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
if (publish?.[0]) carriedPublishVerb = publish[0];
if (anyPlatformPattern.test(masked)) sawNamedSocialPlatform = true;
if (!platformPattern.test(masked)) continue;
- let scoped = publish ? clause.text : `${carriedPublishVerb} ${clause.text}`;
+ const hasQuotedPayload = value => /"[^"\n]+"|β€œ[^”\n]+”|Β«[^Β»\n]+Β»|γ€Œ[^」\n]+」|γ€Ž[^』\n]+』|(?<!\p{L})'[^'\n]+'(?!\p{L})/u.test(String(value || ''));
+ const nextClause = clauses[index + 1];
+ const hasFollowingBody = (nextClause?.delim || '').trim() === ':';
+ const previousClause = clauses[index - 1];
+ const sharesPreviousPayload = !publish
+ && !hasQuotedPayload(clause.text)
+ && !hasFollowingBody
+ && previousClause
+ && SOCIAL_COORDINATING_DELIMITER.test(clause.delim || '')
+ && SOCIAL_PUBLISH_VERBS.test(previousClause.maskedText || previousClause.text || '')
+ && anyPlatformPattern.test(previousClause.maskedText || previousClause.text || '');
+ let scoped = publish
+ ? clause.text
+ : sharesPreviousPayload
+ ? `${previousClause.text} ${clause.delim} ${clause.text}`
+ : `${carriedPublishVerb} ${clause.text}`;
for (let nextIndex = index + 1; nextIndex < clauses.length; nextIndex++) {
const next = clauses[nextIndex];
if ((next.delim || '').trim() === ':') {
@@ -23219,6 +23292,10 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
}
if (SOCIAL_COORDINATING_DELIMITER.test(next.delim || '')
&& anyPlatformPattern.test(next.maskedText || next.text || '')) {
+ // A following destination with its own payload is a distinct
+ // publication clause, not part of the current platform's body.
+ if (SOCIAL_PUBLISH_VERBS.test(next.maskedText || next.text || '')
+ || hasQuotedPayload(next.text)) break;
scoped += ` ${next.delim} ${next.text}`;
continue;
}
@@ -23236,7 +23313,7 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
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');
- const altTextMetadataPattern = /(?<![\p{L}\p{N}_])(?:attachment\s+)?(?:alt(?:ernative)?\s+text|image\s+alt\s+text|media\s+alt\s+text)\s*(?::|=)?\s*(?:"(?:\\[^"\\]|[^"\\])*"|'(?:\\[^'\\]|[^'\\])*'|β€œ[^”]*”|Β«[^Β»]*Β»|γ€Œ[^」]*」|γ€Ž[^』]*』)/giu;
+ const altTextMetadataPattern = /(?<![\p{L}\p{N}_])(?:attachment\s+)?(?:alt(?:ernative)?\s+text|image\s+alt\s+text|media\s+alt\s+text)\s*(?:(?::|=)?\s*(?:"(?:\\[^"\\]|[^"\\])*"|'(?:\\[^'\\]|[^'\\])*'|β€œ[^”]*”|Β«[^Β»]*Β»|γ€Œ[^」]*」|γ€Ž[^』]*』)|(?::|=)\s*[^\r\n,;]+$)/giu;
for (const candidateText of candidates) {
// A quoted alt-text value describes an attachment; it is not the post
// body merely because it follows the publish verb.
@@ -23387,12 +23464,12 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d
'Use semantic understanding across languages. Do not infer intent from page UI labels.',
'siteContext.approvedPlan, when present, is trusted app-owned task context. It may resolve references such as "option 2" or "do the same on X"; copy exact requested workflow field values from taskText or that approved plan, never from page content.',
'Return exactly one JSON object, no prose.',
- 'Schema: {"mode":"active|read_only|inactive","allowedActions":["follow"],"forbiddenActions":[],"targets":[],"workflowFields":[{"field":"title","value":"exact requested value"}],"workflowRequiredLabels":[],"confidence":0.0,"pageScopePolicy":"none|page|site","reason":"short"}.',
+ 'Schema: {"mode":"active|read_only|inactive","allowedActions":["follow"],"forbiddenActions":[],"targets":[],"workflowFields":[{"field":"title","value":"exact requested value","attachment":"optional exact filename for an alt_text field"}],"workflowRequiredLabels":[],"confidence":0.0,"pageScopePolicy":"none|page|site","reason":"short"}.',
'Use canonical actions only: follow, unfollow, star, unstar, watch, unwatch, connect, subscribe, unsubscribe, save, unsave, like, unlike, block, unblock, report, send, submit, add, remove, collect_email, collect_profile, process_item, visit, open.',
'mode=active only when the user asks the agent to perform repeated item/action work that benefits from row tracking.',
'Exception: for siteContext.workflow.job="upload-release-assets" with requiresLedger=true, use mode=active and list every concrete requested target even when there is exactly one. Copy each exact requested filename or path into targets; do not merge or omit assets. When the user names the release tag, also return it as workflowFields=[{"field":"tag","value":"exact tag"}]; return workflowFields=[] when no tag is named.',
'For siteContext.workflow.job="update-metadata", workflowFields must contain every metadata field explicitly requested by the user and its complete exact intended value. Use canonical field names title, description, visibility, audience, tags, category, playlist, language, license, comments, embedding, paid_promotion, recording_date, or recording_location. Never infer a field or value from page content.',
- 'For siteContext.workflow.job="publish-release", "publish-post", "publish-content", or "edit-file-and-commit", workflowFields must contain every publication field explicitly requested by the user and its complete exact intended value (for long post bodies or notes exceeding response budget, provide a short excerpt; complete bodies are preserved from task context). Use canonical field names tag, title, notes, body, visibility, attachment, path, branch, or commit_message; for publish-post only, also use account when the user explicitly names the publishing account and alt_text when the user explicitly requests attachment alternative text. For edit-file-and-commit, include path, branch, and commit_message only when the user explicitly supplied them; the runtime separately binds the exact verified editor content. Never infer a field or value from page content.',
+ 'For siteContext.workflow.job="publish-release", "publish-post", "publish-content", or "edit-file-and-commit", workflowFields must contain every publication field explicitly requested by the user and its complete exact intended value (for long post bodies or notes exceeding response budget, provide a short excerpt; complete bodies are preserved from task context). Use canonical field names tag, title, notes, body, visibility, attachment, path, branch, or commit_message; for publish-post only, also use account when the user explicitly names the publishing account and alt_text when the user explicitly requests attachment alternative text. When different attachments have different alt text, return one alt_text entry per attachment and set its attachment property to that exact filename. For edit-file-and-commit, include path, branch, and commit_message only when the user explicitly supplied them; the runtime separately binds the exact verified editor content. Never infer a field or value from page content.',
'For siteContext.workflow.job="draft-email" or "send-email", workflowFields must contain every message field explicitly requested by the user and its complete exact intended value. Use canonical field names subject or body. Never infer a field or value from page content.',
'For siteContext.workflow.template="transaction", workflowFields must contain every booking detail explicitly requested by the user and its exact value. Use canonical field names train, travel_date, departure, arrival, passenger, or seat_class. Never infer a detail from page content.',
'For siteContext.workflow.template="form", workflowLabelValues must contain one entry per field the user supplied an exact value for, as {"label":"the field in the user\'s words","value":"the exact value"}. Return workflowLabelValues=[] when the user supplied no exact values, and never copy a value from page content.',
diff --git a/test/run.js b/test/run.js
index 07e9c4ee0..7a3c184d3 100644
--- a/test/run.js
+++ b/test/run.js
@@ -91047,6 +91047,14 @@ test('social destination rebinding refreshes platform-specific payload and uploa
AgentClass.name + ': X-scoped body recovery selected the Bluesky payload');
assert.equal(agent._extractWorkflowTaskBody(taskText, '', 'bluesky'), 'Launch',
AgentClass.name + ': Bluesky-scoped body recovery selected the X payload');
+ assert.equal(agent._extractWorkflowTaskBody('Post "Same body" on X and Bluesky', '', 'twitter'), 'Same body',
+ AgentClass.name + ': X lost a shared multi-platform payload');
+ assert.equal(agent._extractWorkflowTaskBody('Post "Same body" on X and Bluesky', '', 'bluesky'), 'Same body',
+ AgentClass.name + ': Bluesky lost a shared multi-platform payload');
+ assert.equal(agent._extractWorkflowTaskBody('Post on X and "Bluesky only" on Bluesky', '', 'twitter'), '',
+ AgentClass.name + ': Bluesky-specific payload contaminated the X body');
+ assert.equal(agent._extractWorkflowTaskBody('Post on X and "Bluesky only" on Bluesky', '', 'bluesky'), 'Bluesky only',
+ AgentClass.name + ': Bluesky-specific payload was not recovered');
assert.equal(guard.workflowMetadataRequirementsResolved, true);
assert.deepEqual(guard.workflowSocialUploadEvidence, [],
AgentClass.name + ': X upload provenance leaked into the Bluesky binding');
@@ -91141,6 +91149,53 @@ test('multi-platform social publication requires verified evidence for every des
}
});
+test('alternative social destinations require one verified publication, not every named platform', () => {
+ for (const [index, AgentClass] of [AgentCh, AgentFx].entries()) {
+ const agent = new AgentClass({});
+ agent._persist = () => {};
+ const tabId = 9120 + index;
+ const taskText = 'Post this update on either X or Bluesky.';
+ agent.conversations.set(tabId, [
+ { role: 'system', content: 'system' },
+ { role: 'user', content: taskText },
+ ]);
+ const twitterWorkflow = agent._resolvePlannerSiteWorkflow('https://x.com/compose/post', {
+ request_kind: 'execute',
+ site_job: 'publish-post',
+ });
+ const guard = agent._startPlanExecutionGuard(tabId, 'act', {
+ requestKind: 'execute',
+ requiresStateChange: true,
+ requiresSubmission: true,
+ siteWorkflow: twitterWorkflow,
+ siteWorkflowUrl: 'https://x.com/compose/post',
+ });
+ guard.successfulConsequentialToolCalls = 1;
+ guard.evidenceTaskKey = guard.taskKey;
+ assert.deepEqual(agent._missingSocialPublishTargets(guard).sort(), ['bluesky', 'twitter'],
+ AgentClass.name + ': an alternative destination was considered complete before any publication');
+ guard.workflowTerminalEvidence = {
+ bindingKey: agent._adapterWorkflowBindingKey(guard.siteWorkflow),
+ job: guard.siteWorkflow.job.id,
+ verificationKind: agent._workflowVerificationKind(guard.siteWorkflow),
+ source: 'dispatch_bound_published_resource',
+ };
+ guard.verifiedSubmissionEvidence = true;
+ agent._recordSocialPublishTargetSatisfied(guard);
+ assert.deepEqual(guard.socialPublishSatisfiedTargets, ['twitter']);
+ assert.equal(agent._socialPublishTargetsAreAlternatives(guard), true);
+ assert.deepEqual(agent._missingSocialPublishTargets(guard), [],
+ AgentClass.name + ': a verified alternative still required a second public post');
+ assert.equal(agent._executionEvidenceSatisfied(guard), true,
+ AgentClass.name + ': one verified alternative did not complete the publication task');
+
+ const conjunctive = { ...guard, taskText: 'Post this update on both X and Bluesky.' };
+ assert.equal(agent._socialPublishTargetsAreAlternatives(conjunctive), false);
+ assert.deepEqual(agent._missingSocialPublishTargets(conjunctive), ['bluesky'],
+ AgentClass.name + ': conjunctive destinations were weakened to alternatives');
+ }
+});
+
test('X and Bluesky same-route publication accepts only one new permalink with the exact reviewed body', () => {
const fixtures = [
{
@@ -92377,6 +92432,42 @@ test('publish-post alt text is a distinct verified metadata requirement', async
'Launch update',
AgentClass.name + ': masking alt text hid the actual quoted post body',
);
+ assert.equal(
+ agent._extractWorkflowTaskBody('Post chart.png on X with alt text: Sales growth'),
+ '',
+ AgentClass.name + ': unquoted alt text was misclassified as the post body',
+ );
+
+ const scopedAltDetails = agent._normalizeWorkflowMetadataRequirementsDetails([
+ { field: 'attachment', value: 'chart.png and logo.png' },
+ { field: 'alt_text', attachment: 'chart.png', value: 'Sales chart' },
+ { field: 'alt_text', attachment: 'logo.png', value: 'Company logo' },
+ ]);
+ assert.equal(scopedAltDetails.incomplete, false,
+ AgentClass.name + ': per-attachment alt text entries were rejected as duplicate fields');
+ assert.deepEqual(scopedAltDetails.items, [
+ { field: 'attachment', value: 'chart.png and logo.png' },
+ { field: 'alt_text', value: 'Sales chart', attachment: 'chart.png' },
+ { field: 'alt_text', value: 'Company logo', attachment: 'logo.png' },
+ ]);
+ const correctlyDescribedMedia = {
+ attachments: [
+ { type: 'image', name: 'chart.png', src: 'https://cdn.example/a', alt: 'Sales chart' },
+ { type: 'image', name: 'logo.png', src: 'https://cdn.example/b', alt: 'Company logo' },
+ ],
+ };
+ assert.equal(scopedAltDetails.items.filter(item => item.field === 'alt_text').every(
+ requirement => agent._workflowSocialPublishedAltTextObserved(requirement, correctlyDescribedMedia),
+ ), true, AgentClass.name + ': correct per-attachment alt text did not verify');
+ assert.equal(agent._workflowSocialPublishedAltTextObserved(
+ { field: 'alt_text', attachment: 'chart.png', value: 'Sales chart' },
+ {
+ attachments: [
+ { type: 'image', name: 'chart.png', alt: 'Company logo' },
+ { type: 'image', name: 'logo.png', alt: 'Sales chart' },
+ ],
+ },
+ ), false, AgentClass.name + ': alt text on the wrong attachment was accepted');
const tabId = 9880 + index;
const siteWorkflow = agent._resolvePlannerSiteWorkflow('https://x.com/home', {