Skip to content

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

Give the completion verifier tests' agent the submit-state accessor

Claude01823c1379aa
diff --git a/test/completion-document.mjs b/test/completion-document.mjs
index a9bac2b3e..9f2977b88 100644
--- a/test/completion-document.mjs
+++ b/test/completion-document.mjs
@@ -35,7 +35,7 @@ for (const [build, browserType] of [['chrome', chromium], ['firefox', firefox]])
_activeProvider: () => provider, _runAbortSignal: () => null, systemOneContext: () => ({ isCurrent: () => true }),
_latestTaskText: () => 'Check this checkbox', _originalTaskText: () => '', _progressTaskKeyHash: () => 'check',
_planExecutionGuards: new Map(), completionInvariants: new Map([[1, { runToken: 'run' }]]),
- _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(), _completionDocumentStamp: stamp,
+ _currentCompletionSubmitState(tab) { return this._completionSubmitStates.get(tab) || null; }, _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(), _completionDocumentStamp: stamp,
executeTool: async () => ({ success: true, ...await page.evaluate(() => window.__generateAccessibilityTree('all', 15, 5500)) }), recordSystemOneVerdict() {},
evaluateSystemOne: async () => {
await page.locator('#check').evaluate(element => { element.checked = false; });
@@ -75,7 +75,7 @@ for (const [build, browserType] of [['chrome', chromium], ['firefox', firefox]])
_activeProvider: () => provider, _runAbortSignal: () => null, systemOneContext: () => ({ isCurrent: () => true }),
_latestTaskText: () => 'Verify the requested emoji', _originalTaskText: () => '', _progressTaskKeyHash: () => 'emoji',
_planExecutionGuards: new Map(), completionInvariants: new Map([[1, { runToken: 'run' }]]),
- _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(), _completionDocumentStamp: stamp,
+ _currentCompletionSubmitState(tab) { return this._completionSubmitStates.get(tab) || null; }, _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(), _completionDocumentStamp: stamp,
executeTool: async () => ({ success: true, ...await page.evaluate(() => window.__generateAccessibilityTree('all', 15, 5500)) }), recordSystemOneVerdict() {},
evaluateSystemOne: async () => {
await replace('😁');
@@ -107,7 +107,7 @@ for (const [build, browserType] of [['chrome', chromium], ['firefox', firefox]])
_activeProvider: () => provider, _runAbortSignal: () => null, systemOneContext: () => ({ isCurrent: () => true }),
_latestTaskText: () => 'Verify the requested post was published', _originalTaskText: () => '', _progressTaskKeyHash: () => 'post',
_planExecutionGuards: new Map(), completionInvariants: new Map([[1, { runToken: 'run' }]]),
- _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(),
+ _currentCompletionSubmitState(tab) { return this._completionSubmitStates.get(tab) || null; }, _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(),
_completionDocumentStamp: (_tab, documentOnly) => page.evaluate(documentOnly ? COMPLETION_DOCUMENT_IDENTITY_SCRIPT : COMPLETION_DOCUMENT_STAMP_SCRIPT),
executeTool: async () => { reads++; return { success: true, ...await page.evaluate(() => window.__generateAccessibilityTree('all', 15, 5500)) }; }, recordSystemOneVerdict() {},
evaluateSystemOne: async (_tab, _client, args) => {
diff --git a/test/completion-verifier.mjs b/test/completion-verifier.mjs
index 54067dfef..e72acc87b 100644
--- a/test/completion-verifier.mjs
+++ b/test/completion-verifier.mjs
@@ -131,7 +131,7 @@ for (const build of ['chrome', 'firefox']) {
systemOneContext: () => ({ isCurrent: () => true }), _latestTaskText: () => 'Read the community rules and publish a WebBrain post', _originalTaskText: () => '',
_progressTaskKeyHash: () => 'task-key', _planExecutionGuards: new Map([[1, guard]]),
completionInvariants: new Map([[1, { runToken: 'run', historyToolCallIdsBeforeRun: new Set(), lastAction: { sequence: 2, name: 'click' } }]]),
- _completionSubmitStates: new Map([[1, { dispatched: true, observedAfterSubmit: true, currentUrl: 'https://old.reddit.com/comments/new', workflowBinding: {
+ _currentCompletionSubmitState(tab) { return this._completionSubmitStates.get(tab) || null; }, _completionSubmitStates: new Map([[1, { dispatched: true, observedAfterSubmit: true, currentUrl: 'https://old.reddit.com/comments/new', workflowBinding: {
adapterName: 'reddit', revision: '1', job: 'publish', verificationKind: 'published_resource', recipientBound: true,
messageBody: 'unlabelled-entered-value', composerBody: 'nested-entered-value', messageSubject: 'another-entered-value',
recipientTargets: [{ address: 'opaque-entered-value' }], metadataRequirements: [{ field: 'title', value: 'metadata-entered-value' }],
@@ -215,7 +215,7 @@ for (const build of ['chrome', 'firefox']) {
const agent = {
_activeProvider: () => provider, _runAbortSignal: () => null, systemOneContext: () => ({ isCurrent: () => true }),
_latestTaskText: () => 'Read the rules and publish a post', _originalTaskText: () => '', _progressTaskKeyHash: () => 'task',
- _planExecutionGuards: new Map(), completionInvariants: new Map([[1, run]]), _completionSubmitStates: new Map(),
+ _planExecutionGuards: new Map(), completionInvariants: new Map([[1, run]]), _currentCompletionSubmitState(tab) { return this._completionSubmitStates.get(tab) || null; }, _completionSubmitStates: new Map(),
conversationIds: new Map(), conversations: new Map([[1, messages]]), _completionDocumentStamp: async () => 'document',
executeTool: async () => ({ success: true, pageContent: 'Requested post published' }), recordSystemOneVerdict() {},
evaluateSystemOne: async (_tab, _client, args) => { state = args.state; const result = response(JSON.stringify(state).includes('CURRENT') ? 'succeeded' : 'uncertain'); result.model = 'kev-latest'; return result; },
@@ -248,7 +248,7 @@ for (const build of ['chrome', 'firefox']) {
_activeProvider: () => active, _runAbortSignal: () => null, systemOneContext: () => ({ isCurrent: () => true }),
_latestTaskText: () => 'Verify the published image', _originalTaskText: () => '', _progressTaskKeyHash: () => 'task',
_planExecutionGuards: new Map([[1, guard]]), completionInvariants: new Map([[1, { runToken: 'run', lastAction: { sequence: 1 } }]]),
- _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(),
+ _currentCompletionSubmitState(tab) { return this._completionSubmitStates.get(tab) || null; }, _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(),
_completionDocumentStamp: async () => 'unchanged-text-and-inputs',
_captureCompletionJudgeImage: async () => { captures++; return pixels; },
_budgetForCapture: () => ({ maxTargetPx: 1408, maxTargetTokens: 1400 }), _shrinkImageForBudget: async dataUrl => ({ dataUrl }),
@@ -293,7 +293,7 @@ for (const build of ['chrome', 'firefox']) {
_activeProvider: () => provider, _runAbortSignal: () => null, systemOneContext: () => ({ isCurrent: () => true }),
_latestTaskText: () => 'Verify the published post', _originalTaskText: () => '', _progressTaskKeyHash: () => 'task',
_planExecutionGuards: new Map(), completionInvariants: new Map([[1, { runToken: 'run' }]]),
- _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(),
+ _currentCompletionSubmitState(tab) { return this._completionSubmitStates.get(tab) || null; }, _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(),
_completionDocumentStamp: async () => 'same-published-document',
_captureCompletionJudgeImage: async () => `data:image/png;base64,animation-frame-${++captures}`,
_budgetForCapture: () => ({ maxTargetPx: 1408, maxTargetTokens: 1400 }), _shrinkImageForBudget: async dataUrl => ({ dataUrl }),
@@ -332,7 +332,7 @@ for (const build of ['chrome', 'firefox']) {
_activeProvider: () => active, _runAbortSignal: () => null, systemOneContext: () => ({ isCurrent: () => true }),
_latestTaskText: () => 'Verify publication', _originalTaskText: () => '', _progressTaskKeyHash: () => 'task',
_planExecutionGuards: new Map(), completionInvariants: new Map([[1, { runToken: 'run' }]]),
- _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(),
+ _currentCompletionSubmitState(tab) { return this._completionSubmitStates.get(tab) || null; }, _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(),
_completionDocumentStamp: async () => 'stable',
_canTakeAutoScreenshot: (_tabId, slots = 1) => cap === 0 || spent + slots <= cap,
_captureCompletionJudgeImage: async () => { if (cap && spent >= cap) return null; spent++; captures++; return 'data:image/png;base64,stable'; },
@@ -369,7 +369,7 @@ for (const build of ['chrome', 'firefox']) {
_activeProvider: () => provider, _runAbortSignal: () => null, systemOneContext: () => ({ isCurrent: () => current }),
_latestTaskText: () => 'Verify publication', _originalTaskText: () => '', _progressTaskKeyHash: () => 'task',
_planExecutionGuards: new Map(), completionInvariants: new Map([[1, { runToken: 'run' }]]),
- _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(),
+ _currentCompletionSubmitState(tab) { return this._completionSubmitStates.get(tab) || null; }, _completionSubmitStates: new Map(), conversationIds: new Map(), conversations: new Map(),
_completionDocumentStamp: async () => { if (judged) current = false; return 'stable'; },
executeTool: async () => ({ success: true, pageContent: 'Published' }), recordSystemOneVerdict() {},
evaluateSystemOne: async () => { judged = true; const result = response(); result.model = 'kev-latest'; return result; },