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
Compare page fields by the page the read serves
Claude4866738afeae
diff --git a/src/chrome/src/agent/agent.js b/src/chrome/src/agent/agent.jsindex eac781b57..f5e062002 100644--- a/src/chrome/src/agent/agent.js+++ b/src/chrome/src/agent/agent.js@@ -11316,7 +11316,11 @@ export class Agent extends LoopDetector {// case of a filter are normalized, as the call is repaired below.const normalized = (value, key) => {// A page is repaired below from up to four digits ("01" is 1).- if (key === 'page' && typeof value === 'string' && /^\s*\d{1,4}\s*$/.test(value)) return Number(value);+ if (key === 'page') {+ // The page the read serves: Math.max(1, floor(Number(page) || 1)).+ const number = typeof value === 'string' && /^\s*\d{1,4}\s*$/.test(value) ? Number(value) : decimal(value);+ if (typeof number === 'number' && Number.isFinite(number)) return Math.max(1, Math.floor(number) || 1);+ }// The read trims a revision before comparing it; its case is kept.if (key === 'tree_revision' && typeof value === 'string') return value.trim();const scalar = decimal(value);diff --git a/src/firefox/src/agent/agent.js b/src/firefox/src/agent/agent.jsindex cd690c8a8..32a60ff46 100644--- a/src/firefox/src/agent/agent.js+++ b/src/firefox/src/agent/agent.js@@ -10994,7 +10994,11 @@ export class Agent extends LoopDetector {// case of a filter are normalized, as the call is repaired below.const normalized = (value, key) => {// A page is repaired below from up to four digits ("01" is 1).- if (key === 'page' && typeof value === 'string' && /^\s*\d{1,4}\s*$/.test(value)) return Number(value);+ if (key === 'page') {+ // The page the read serves: Math.max(1, floor(Number(page) || 1)).+ const number = typeof value === 'string' && /^\s*\d{1,4}\s*$/.test(value) ? Number(value) : decimal(value);+ if (typeof number === 'number' && Number.isFinite(number)) return Math.max(1, Math.floor(number) || 1);+ }// The read trims a revision before comparing it; its case is kept.if (key === 'tree_revision' && typeof value === 'string') return value.trim();const scalar = decimal(value);diff --git a/test/read-continuation-schema.mjs b/test/read-continuation-schema.mjsindex 2fc693b94..763a50bc7 100644--- a/test/read-continuation-schema.mjs+++ b/test/read-continuation-schema.mjs@@ -234,7 +234,7 @@ for (const browser of ['chrome', 'firefox']) {assert.equal(partial.args.ref_id, 'ref_12');assert.equal(partial.args.filter, 'interactive');// So it is beside values that only differ in type or a filter's case.- for (const top of [{ page: '1' }, { maxChars: '6000' }, { filter: 'INTERACTIVE' }, { maxDepth: ' 15 ' }]) {+ for (const top of [{ page: '1' }, { page: 0 }, { page: 1.5 }, { page: -2 }, { maxChars: '6000' }, { filter: 'INTERACTIVE' }, { maxDepth: ' 15 ' }]) {const mixed = agent._repairToolCallArgs('get_accessibility_tree', { ...top, continuationArgs: restart });assert.equal(mixed.result, undefined, JSON.stringify(top));assert.equal(mixed.args.ref_id, 'ref_12', JSON.stringify(top));