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
Read upload lines by meaning, not by status words in a dozen languages
Claude645f1a423b41
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex f16515fd7..e415bf4e5 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -7,6 +7,7 @@ This changelog was generated from the repository Git history and release tags. V## [Unreleased]### Fixed+- File uploads in forms and release pages: whether the page shows your file as uploaded is now read by a model in any language, instead of looking for words such as "uploaded" or "eklendi". A Polish "cover.pdf · 96 KB · przesłano" now proves the upload, and a line saying the upload failed no longer counts as proof.- Following accounts from a list: on Mastodon, whether an account is already followed, whether the page asks for your own server, and which server your request calls your own are now read by a model in any language, not only in English and Turkish. A German "Gefolgt" now counts as followed, and the follow on a TikTok, Threads or Medium profile is no longer held back waiting for a Mastodon followed state. A click on "Takip et ayşe" or another label in any language is now recorded on the progress list when a model reads it as the run's action, for the row it names.- Search boxes in any language now share the single approval a search gets, instead of asking again for every search. A German site's box under "Suche" or a Turkish "Ara" button counts as a search when the page marks the form as a search, the field's keyboard says search, or a model reads the button as only searching; the English word "Search" in a label no longer decides it either way. Forms that send data, ask for a password or card, or post elsewhere keep their own approval.- Forms: which field of a form you named in your request, and the value you gave it, is now read by a model in any language instead of by matching words. A request in Turkish such as "ön yazımı ekle" now matches an English form's "Cover letter (optional)", so its value counts as entered and the optional field can no longer be skipped. Before, words in different languages never matched, so the form could not be completed, and a field you asked for could be left empty.diff --git a/docs/site-adapters.md b/docs/site-adapters.mdindex eebc5fbe3..52941d6e3 100644--- a/docs/site-adapters.md+++ b/docs/site-adapters.md@@ -96,6 +96,11 @@ unclear), the decision model first, before the reconciliation and again at`done`. A requested value has to read back from a field read as the namedone, and an optional row may be skipped only once every named field reads asa different one; a pair nobody has read yet keeps the row required.+An upload row is proved by the page showing its file beside its own control+after the upload: a line whose name or value is the file name, or another line+naming the file that a model read, in any language, as saying it was uploaded+or attached (`workflow_state`, `file_attached`). A line read as a failed or+unfinished upload proves nothing, and neither does a line nobody has read.Depth truncation is form-relevant (an omitted includable descendant). Emptyor erroring third-party frames are omitted only when another frame alreadyinventoried form controls; a lone failed cross-origin application frame staysdiff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex 230cb4ab9..50655ee8f 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -14304,6 +14304,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d});}const completionStateBeforeTool = this.completionInvariants.get(tabId) || null;+ // An upload's evidence reads the lines that name its file first.+ await this._readWorkflowUploadLines(tabId, fnName, toolResult);const completionStateAfterTool = this._recordCompletionToolResult(tabId,fnName,@@ -19945,18 +19947,80 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (!expected) return 0;const escaped = expected.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');const exactFileName = new RegExp(`(^|[^\\p{L}\\p{N}_.-])${escaped}($|[^\\p{L}\\p{N}_.-])`, 'u');- const attachmentStatus = /\b(?:attached|uploaded|upload complete|upload successful|remove attachment|remove file|delete attachment|replace file)\b|(?:已上传|附件|上传完成|已上傳|上傳完成|添付|アップロード済み|첨부|업로드됨|yüklendi|eklendi)/iu;let count = 0;for (const rawLine of String(value || '').split(/\r?\n/)) {const line = normalize(rawLine);if (!exactFileName.test(line)) continue;const label = normalize(/^\s*[a-z]+\s+"([^"]+)"/i.exec(rawLine)?.[1]);const currentValue = normalize(/\bvalue="([^"]+)"/i.exec(rawLine)?.[1]);- if (label === expected || currentValue === expected || attachmentStatus.test(line)) count += 1;+ // The file's own name or value shows it; any other line that names it+ // shows it when a model read the line, in any language, as saying the+ // file was uploaded or attached. A line read as a failure shows nothing.+ if (label === expected || currentValue === expected+ || this._workflowUploadLineReading(rawLine) === 'reached') count += 1;}return count;}+ // The visible text of an accessibility tree line: its quoted name, or the+ // line itself.+ _workflowAxLineText(rawLine) {+ const quoted = /^\s*[a-z]+\s+"((?:[^"\\]|\\.)+)"/i.exec(String(rawLine || ''))?.[1];+ return String(quoted ? quoted.replace(/\\(["\\])/g, '$1') : rawLine || '').replace(/\s+/g, ' ').trim().slice(0, 300);+ }++ // A model's reading of an upload line, in any language (workflow_state, the+ // file_attached state): reached, failed, other, or null while unread.+ _workflowUploadLineReading(rawLine) {+ return this._pageTextReading('workflow_state', this._workflowAxLineText(rawLine), { state: WORKFLOW_STATES.file_attached });+ }++ // Whether an observation names a file on a line a model read as saying its+ // upload failed or is still under way.+ _workflowUploadFailureShown(value, fileName) {+ let expected = String(fileName || '').replace(/\s+/g, ' ').trim();+ try { expected = expected.normalize('NFKC'); } catch {}+ if (!expected) return false;+ const escaped = expected.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');+ const exactFileName = new RegExp(`(^|[^\\p{L}\\p{N}_.-])${escaped}($|[^\\p{L}\\p{N}_.-])`, 'iu');+ return String(value || '').split(/\r?\n/).some(rawLine => exactFileName.test(rawLine)+ && this._workflowUploadLineReading(rawLine) === 'failed');+ }++ // Reads, in any language, the lines of a page observation that name a file+ // an upload is waiting to see (workflow_state, file_attached), before the+ // synchronous evidence checks: for an upload itself, the lines of the last+ // observation, its baseline; for an observation, its own lines. The+ // decision model first, the active model within four seconds.+ async _readWorkflowUploadLines(tabId, name, result) {+ const guard = this._planExecutionGuards.get(tabId);+ if (!guard?.enabled || !result || typeof result !== 'object' || result.success === false) return;+ let text = '', fileNames = [];+ if (name === 'upload_file') {+ text = String(guard.workflowInventoryObservationText || '');+ fileNames = [this._workflowReleaseAssetFileName(result?.attached?.name)];+ } else if (COMPLETION_DOCUMENT_OBSERVATION_TOOLS.has(name)) {+ text = [result.pageContent, result.text, result.content, result.description]+ .filter(value => typeof value === 'string' && value.trim()).join('\n');+ fileNames = [guard.workflowPendingUploadEvidence, guard.workflowPendingReleaseAssetEvidence]+ .flatMap(pending => Object.values(pending && typeof pending === 'object' ? pending : {}))+ .map(candidate => candidate?.fileName);+ }+ const names = [...new Set(fileNames.map(value => String(value || '').trim()).filter(Boolean))];+ if (!text || !names.length) return;+ const lines = [...new Set(text.split(/\r?\n/)+ .filter(rawLine => names.some(fileName => rawLine.includes(fileName)) && !/\btype="file"/i.test(rawLine))+ .map(rawLine => this._workflowAxLineText(rawLine))+ .filter(line => line && !names.includes(line)))].slice(0, 24);+ if (!lines.length) return;+ try {+ await this._readPageTexts(tabId, 'workflow_state', lines, { state: WORKFLOW_STATES.file_attached },+ { maxChars: 300, mainTimeoutMs: CONTROL_READING_TIMEOUT_MS });+ } catch (error) {+ if (this._checkAbort(tabId)) throw error;+ }+ }+_rememberWorkflowReleaseAssetObservation(tabId, name, result) {const guard = this._planExecutionGuards.get(tabId);if (!this._isWorkflowReleaseAssetJob(guard)@@ -19979,7 +20043,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}for (const [itemId, candidate] of Object.entries(pending)) {if (observationSequence <= Number(candidate?.actionSequence || 0)- || this._workflowReleaseAssetSignalCount(observationText, candidate?.fileName) < 1) continue;+ || this._workflowReleaseAssetSignalCount(observationText, candidate?.fileName) < 1+ || this._workflowUploadFailureShown(observationText, candidate?.fileName)) continue;guard.workflowReleaseAssetEvidence[itemId] = {itemId,tool: 'upload_file',@@ -20042,7 +20107,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst exactItemLabel = itemLabel? new RegExp(`(^|[^\\p{L}\\p{N}_.-])${itemLabel.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}($|[^\\p{L}\\p{N}_.-])`, 'u'): null;- const attachmentStatus = /\b(?:attached|uploaded|upload complete|upload successful|remove attachment|remove file|delete attachment|replace file)\b|(?:fichier joint|téléversé|supprimer|hochgeladen|entfernen|adjunto|subido|eliminar|caricato|rimuovi|eklendi|yüklendi|kaldır|添付|アップロード済み|削除|첨부|업로드됨|삭제|已上传|附件|移除|上傳完成|загруж|прикреп|удал)/iu;const lines = String(value || '').split(/\r?\n/);const fileControls = lines.flatMap((rawLine, index) => {if (!/\btype="file"/i.test(rawLine)) return [];@@ -20065,7 +20129,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (!exactFileName.test(line) || /\btype="file"/i.test(rawLine)) continue;const label = normalize(/^\s*[a-z]+\s+"([^"]+)"/i.exec(rawLine)?.[1]);const currentValue = normalize(/\bvalue="([^"]+)"/i.exec(rawLine)?.[1]);- if (label !== expected && currentValue !== expected && !attachmentStatus.test(line)) continue;+ // The file's own name or value shows it; any other line that names it+ // shows it when a model read the line, in any language, as saying the+ // file was uploaded or attached.+ if (label !== expected && currentValue !== expected+ && this._workflowUploadLineReading(rawLine) !== 'reached') continue;const labelledWidgetSignal = exactItemLabel?.test(line) === true;if (fileControls.length) {const distances = fileControls.map(control => ({ control, distance: Math.abs(control.index - index) }));@@ -20097,7 +20165,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dcandidate?.fileName,candidate?.item,);- if (observedCount <= Number(candidate?.baselineUiSignalCount || 0)) continue;+ if (observedCount <= Number(candidate?.baselineUiSignalCount || 0)+ || this._workflowUploadFailureShown(observationText, candidate?.fileName)) continue;guard.workflowControlActionEvidence[itemId] = {itemId,tool: 'upload_file',diff --git a/src/chrome/src/agent/semantic-decisions.js b/src/chrome/src/agent/semantic-decisions.jsindex dfbbaa0c9..21276da48 100644--- a/src/chrome/src/agent/semantic-decisions.js+++ b/src/chrome/src/agent/semantic-decisions.js@@ -351,6 +351,7 @@ export const WORKFLOW_STATES = Object.freeze({form_submitted: 'the form or application was submitted and received',changes_saved: 'the changes were saved',threads_resolved: 'the review conversation or thread was marked as resolved',+ file_attached: 'the file named in the text was uploaded or attached',});export function semanticQuestion(kind) {diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex b0c4977c8..f052d0457 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -12855,6 +12855,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d});}const completionStateBeforeTool = this.completionInvariants.get(tabId) || null;+ // An upload's evidence reads the lines that name its file first.+ await this._readWorkflowUploadLines(tabId, fnName, toolResult);const completionStateAfterTool = this._recordCompletionToolResult(tabId,fnName,@@ -17432,18 +17434,80 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (!expected) return 0;const escaped = expected.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');const exactFileName = new RegExp(`(^|[^\\p{L}\\p{N}_.-])${escaped}($|[^\\p{L}\\p{N}_.-])`, 'u');- const attachmentStatus = /\b(?:attached|uploaded|upload complete|upload successful|remove attachment|remove file|delete attachment|replace file)\b|(?:已上传|附件|上传完成|已上傳|上傳完成|添付|アップロード済み|첨부|업로드됨|yüklendi|eklendi)/iu;let count = 0;for (const rawLine of String(value || '').split(/\r?\n/)) {const line = normalize(rawLine);if (!exactFileName.test(line)) continue;const label = normalize(/^\s*[a-z]+\s+"([^"]+)"/i.exec(rawLine)?.[1]);const currentValue = normalize(/\bvalue="([^"]+)"/i.exec(rawLine)?.[1]);- if (label === expected || currentValue === expected || attachmentStatus.test(line)) count += 1;+ // The file's own name or value shows it; any other line that names it+ // shows it when a model read the line, in any language, as saying the+ // file was uploaded or attached. A line read as a failure shows nothing.+ if (label === expected || currentValue === expected+ || this._workflowUploadLineReading(rawLine) === 'reached') count += 1;}return count;}+ // The visible text of an accessibility tree line: its quoted name, or the+ // line itself.+ _workflowAxLineText(rawLine) {+ const quoted = /^\s*[a-z]+\s+"((?:[^"\\]|\\.)+)"/i.exec(String(rawLine || ''))?.[1];+ return String(quoted ? quoted.replace(/\\(["\\])/g, '$1') : rawLine || '').replace(/\s+/g, ' ').trim().slice(0, 300);+ }++ // A model's reading of an upload line, in any language (workflow_state, the+ // file_attached state): reached, failed, other, or null while unread.+ _workflowUploadLineReading(rawLine) {+ return this._pageTextReading('workflow_state', this._workflowAxLineText(rawLine), { state: WORKFLOW_STATES.file_attached });+ }++ // Whether an observation names a file on a line a model read as saying its+ // upload failed or is still under way.+ _workflowUploadFailureShown(value, fileName) {+ let expected = String(fileName || '').replace(/\s+/g, ' ').trim();+ try { expected = expected.normalize('NFKC'); } catch {}+ if (!expected) return false;+ const escaped = expected.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');+ const exactFileName = new RegExp(`(^|[^\\p{L}\\p{N}_.-])${escaped}($|[^\\p{L}\\p{N}_.-])`, 'iu');+ return String(value || '').split(/\r?\n/).some(rawLine => exactFileName.test(rawLine)+ && this._workflowUploadLineReading(rawLine) === 'failed');+ }++ // Reads, in any language, the lines of a page observation that name a file+ // an upload is waiting to see (workflow_state, file_attached), before the+ // synchronous evidence checks: for an upload itself, the lines of the last+ // observation, its baseline; for an observation, its own lines. The+ // decision model first, the active model within four seconds.+ async _readWorkflowUploadLines(tabId, name, result) {+ const guard = this._planExecutionGuards.get(tabId);+ if (!guard?.enabled || !result || typeof result !== 'object' || result.success === false) return;+ let text = '', fileNames = [];+ if (name === 'upload_file') {+ text = String(guard.workflowInventoryObservationText || '');+ fileNames = [this._workflowReleaseAssetFileName(result?.attached?.name)];+ } else if (COMPLETION_DOCUMENT_OBSERVATION_TOOLS.has(name)) {+ text = [result.pageContent, result.text, result.content, result.description]+ .filter(value => typeof value === 'string' && value.trim()).join('\n');+ fileNames = [guard.workflowPendingUploadEvidence, guard.workflowPendingReleaseAssetEvidence]+ .flatMap(pending => Object.values(pending && typeof pending === 'object' ? pending : {}))+ .map(candidate => candidate?.fileName);+ }+ const names = [...new Set(fileNames.map(value => String(value || '').trim()).filter(Boolean))];+ if (!text || !names.length) return;+ const lines = [...new Set(text.split(/\r?\n/)+ .filter(rawLine => names.some(fileName => rawLine.includes(fileName)) && !/\btype="file"/i.test(rawLine))+ .map(rawLine => this._workflowAxLineText(rawLine))+ .filter(line => line && !names.includes(line)))].slice(0, 24);+ if (!lines.length) return;+ try {+ await this._readPageTexts(tabId, 'workflow_state', lines, { state: WORKFLOW_STATES.file_attached },+ { maxChars: 300, mainTimeoutMs: CONTROL_READING_TIMEOUT_MS });+ } catch (error) {+ if (this._checkAbort(tabId)) throw error;+ }+ }+_rememberWorkflowReleaseAssetObservation(tabId, name, result) {const guard = this._planExecutionGuards.get(tabId);if (!this._isWorkflowReleaseAssetJob(guard)@@ -17466,7 +17530,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout d}for (const [itemId, candidate] of Object.entries(pending)) {if (observationSequence <= Number(candidate?.actionSequence || 0)- || this._workflowReleaseAssetSignalCount(observationText, candidate?.fileName) < 1) continue;+ || this._workflowReleaseAssetSignalCount(observationText, candidate?.fileName) < 1+ || this._workflowUploadFailureShown(observationText, candidate?.fileName)) continue;guard.workflowReleaseAssetEvidence[itemId] = {itemId,tool: 'upload_file',@@ -17529,7 +17594,6 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dconst exactItemLabel = itemLabel? new RegExp(`(^|[^\\p{L}\\p{N}_.-])${itemLabel.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}($|[^\\p{L}\\p{N}_.-])`, 'u'): null;- const attachmentStatus = /\b(?:attached|uploaded|upload complete|upload successful|remove attachment|remove file|delete attachment|replace file)\b|(?:fichier joint|téléversé|supprimer|hochgeladen|entfernen|adjunto|subido|eliminar|caricato|rimuovi|eklendi|yüklendi|kaldır|添付|アップロード済み|削除|첨부|업로드됨|삭제|已上传|附件|移除|上傳完成|загруж|прикреп|удал)/iu;const lines = String(value || '').split(/\r?\n/);const fileControls = lines.flatMap((rawLine, index) => {if (!/\btype="file"/i.test(rawLine)) return [];@@ -17552,7 +17616,11 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dif (!exactFileName.test(line) || /\btype="file"/i.test(rawLine)) continue;const label = normalize(/^\s*[a-z]+\s+"([^"]+)"/i.exec(rawLine)?.[1]);const currentValue = normalize(/\bvalue="([^"]+)"/i.exec(rawLine)?.[1]);- if (label !== expected && currentValue !== expected && !attachmentStatus.test(line)) continue;+ // The file's own name or value shows it; any other line that names it+ // shows it when a model read the line, in any language, as saying the+ // file was uploaded or attached.+ if (label !== expected && currentValue !== expected+ && this._workflowUploadLineReading(rawLine) !== 'reached') continue;const labelledWidgetSignal = exactItemLabel?.test(line) === true;if (fileControls.length) {const distances = fileControls.map(control => ({ control, distance: Math.abs(control.index - index) }));@@ -17584,7 +17652,8 @@ Rules: no prose intro, no conclusion, no "this screenshot shows...", no layout dcandidate?.fileName,candidate?.item,);- if (observedCount <= Number(candidate?.baselineUiSignalCount || 0)) continue;+ if (observedCount <= Number(candidate?.baselineUiSignalCount || 0)+ || this._workflowUploadFailureShown(observationText, candidate?.fileName)) continue;guard.workflowControlActionEvidence[itemId] = {itemId,tool: 'upload_file',diff --git a/src/firefox/src/agent/semantic-decisions.js b/src/firefox/src/agent/semantic-decisions.jsindex dfbbaa0c9..21276da48 100644--- a/src/firefox/src/agent/semantic-decisions.js+++ b/src/firefox/src/agent/semantic-decisions.js@@ -351,6 +351,7 @@ export const WORKFLOW_STATES = Object.freeze({form_submitted: 'the form or application was submitted and received',changes_saved: 'the changes were saved',threads_resolved: 'the review conversation or thread was marked as resolved',+ file_attached: 'the file named in the text was uploaded or attached',});export function semanticQuestion(kind) {diff --git a/test/run.js b/test/run.jsindex 4dcc172c8..c30bc9110 100644--- a/test/run.js+++ b/test/run.js@@ -94509,10 +94509,17 @@ test('planner intent carries submit-required completion metadata into the execut});});-test('adapter workflow jobs reach the executor and require submit plus complete reconciliation evidence', () => {+test('adapter workflow jobs reach the executor and require submit plus complete reconciliation evidence', async () => {for (const [index, AgentClass] of [AgentCh, AgentFx].entries()) {const agent = new AgentClass({});agent.useSiteAdapters = true;+ // A model reads the lines naming an uploaded file (workflow_state,+ // file_attached); the fixture oracle stands in.+ stubPageTextReadings(agent);+ const observeUpload = async (tab, result) => {+ await agent._readWorkflowUploadLines(tab, 'get_accessibility_tree', result);+ return agent._recordCompletionToolResult(tab, 'get_accessibility_tree', {}, result);+ };const formUrl = 'https://forms.cloud.microsoft/pages/responsepage.aspx?id=x';const selected = agent._resolvePlannerSiteWorkflow(formUrl, {request_kind: 'execute',@@ -94839,7 +94846,7 @@ test('adapter workflow jobs reach the executor and require submit plus complete'button "Upload résumé" [ref_resume_multi] type="file" dom_id="resume-upload" field_name="resume"','button "Upload cover letter" [ref_cover_multi] type="file" dom_id="cover-upload" field_name="cover"',];- agent._recordCompletionToolResult(multiUploadTabId, 'get_accessibility_tree', {}, {+ await observeUpload(multiUploadTabId, {success: true,pageUrl: formUrl,pageContent: [@@ -94851,14 +94858,14 @@ test('adapter workflow jobs reach the executor and require submit plus complete});assert.equal(Object.keys(multiUploadGuard.workflowControlActionEvidence || {}).length, 1,`${AgentClass.name}: an attachment name beside the wrong widget promoted a consumed upload`);- agent._recordCompletionToolResult(multiUploadTabId, 'get_accessibility_tree', {}, {+ await observeUpload(multiUploadTabId, {success: true,pageUrl: formUrl,pageContent: [...multiUploadControls, 'status "mycover.pdf uploaded" [ref_cover_collision]'].join('\n'),});assert.equal(Object.keys(multiUploadGuard.workflowControlActionEvidence || {}).length, 1,`${AgentClass.name}: a filename substring promoted a consumed upload`);- agent._recordCompletionToolResult(multiUploadTabId, 'get_accessibility_tree', {}, {+ await observeUpload(multiUploadTabId, {success: true,pageUrl: formUrl,pageContent: [@@ -95077,6 +95084,44 @@ test('adapter workflow jobs reach the executor and require submit plus complete}});++test('an upload is seen on the page when a model reads the line naming its file, in any language', async () => {+ for (const [index, AgentClass] of [AgentCh, AgentFx].entries()) {+ const agent = new AgentClass({});+ agent.useSiteAdapters = true;+ const formUrl = 'https://forms.cloud.microsoft/pages/responsepage.aspx?id=upload-lines';+ const selected = agent._resolvePlannerSiteWorkflow(formUrl, { request_kind: 'execute', site_job: 'submit-form' });+ // A model reads each line naming the file; these answers stand in.+ const readings = new Map([['cover.pdf · 96 KB · przesłano', 'reached'], ['cover.pdf · przesyłanie nie powiodło się', 'failed']]);+ const asked = stubPageTextReadings(agent, (kind, item) => (kind === 'workflow_state' ? readings.get(item.text) || null : null));+ const run = async (tabId, line) => {+ agent.conversations.set(tabId, [{ role: 'system', content: 'sys' }, { role: 'user', content: 'Attach cover.pdf and submit.' }]);+ const guard = agent._startPlanExecutionGuard(tabId, 'act', { requestKind: 'execute', requiresStateChange: true,+ requiresSubmission: true, siteWorkflow: selected });+ agent._lastAxScopes.set(tabId, { documentToken: `upload-lines-${tabId}`, pageUrl: formUrl });+ const control = 'button "Upload cover letter" [ref_cover] type="file" dom_id="cover-upload" field_name="cover"';+ const inventory = agent._rememberWorkflowInventoryObservation(tabId, 'get_accessibility_tree', {},+ { success: true, pageUrl: formUrl, pageContent: control });+ agent._beginCompletionInvariant(tabId);+ const upload = { success: true, dispatched: true, attachmentState: 'page_consumed', attached: { name: 'cover.pdf', size: 96 },+ uploadTarget: { selector: '#cover-upload', domId: 'cover-upload', fieldName: 'cover', label: 'Upload cover letter' } };+ await agent._readWorkflowUploadLines(tabId, 'upload_file', upload);+ agent._recordCompletionToolResult(tabId, 'upload_file', { selector: '#cover-upload' }, upload);+ const observation = { success: true, pageUrl: formUrl, pageContent: [control, `generic "${line}" [ref_cover_status]`].join('\n') };+ await agent._readWorkflowUploadLines(tabId, 'get_accessibility_tree', observation);+ agent._recordCompletionToolResult(tabId, 'get_accessibility_tree', {}, observation);+ return guard.workflowControlActionEvidence?.[inventory.items[0].id];+ };+ const shown = await run(9470 + index * 3, 'cover.pdf · 96 KB · przesłano');+ assert.equal(shown?.attachmentState, 'page_consumed_observed', `${AgentClass.name}: a Polish upload line was not read as shown`);+ assert.ok(asked.some(item => item.kind === 'workflow_state' && item.text === 'cover.pdf · 96 KB · przesłano'+ && /uploaded or attached/.test(item.state)));+ assert.equal(await run(9471 + index * 3, 'cover.pdf · przesyłanie nie powiodło się'), undefined,+ `${AgentClass.name}: a line read as a failed upload showed the file`);+ assert.equal(await run(9472 + index * 3, 'cover.pdf · 96 KB · gotowe'), undefined,+ `${AgentClass.name}: a line nobody read showed the file`);+ }+});test('iframe-backed application forms expose a complete trusted inventory and exact row evidence', () => {for (const [index, AgentClass] of [AgentCh, AgentFx].entries()) {const agent = new AgentClass({});diff --git a/test/semantic-decision-stub.mjs b/test/semantic-decision-stub.mjsindex a83998ab8..d4e467fd5 100644--- a/test/semantic-decision-stub.mjs+++ b/test/semantic-decision-stub.mjs@@ -191,6 +191,7 @@ const FIXTURE_WORKFLOW_STATES = [[/submitted and received/i, /\bresponse\s+(?:was\s+)?submitted\b|\bapplication\s+(?:was\s+)?(?:submitted|received)\b|\bthank you for (?:submitting|applying)\b|提交成功|başvurunuz alındı/i],[/changes were saved/i, /\bchanges?\s+saved\b|\bsaved successfully\b|保存成功|başarıyla kaydedildi/i],[/resolved/i, /\b(?:conversation|thread|review)\s+(?:was\s+)?(?:marked\s+as\s+)?resolved\b|已解决|çözüldü/i],+ [/uploaded or attached/i, /\b(?:uploaded|attached|upload (?:complete|successful))\b|yüklendi|eklendi|hochgeladen|przesłano|已上传|上傳完成|アップロード済み|업로드됨/iu],];export function fixtureWorkflowStateReading(state, text) {const value = String(text || '');