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
export const workflows = [
{ id: 'search', en: 'Search for Ada and report the visible result.', tr: 'Ada için arama yap ve görünen sonucu bildir.', body: '<form id="search"><label>Search<input id="query" aria-label="Search"></label><button>Search</button></form>', code: `search.onsubmit=e=>{e.preventDefault();record(query.value==='Ada');status.textContent=query.value==='Ada'?'Found: Ada Lovelace':'No result'}` },
{ id: 'filter', en: 'Filter records to Active and report the result.', tr: 'Kayıtları Active durumuna göre filtrele ve sonucu bildir.', body: '<label>Status<select id="filter" aria-label="Status"><option>All</option><option>Active</option><option>Inactive</option></select></label>', code: `filter.onchange=()=>{record(filter.value==='Active');status.textContent='Filtered: '+filter.value+' — Ada'}` },
{ id: 'dynamic', en: 'Choose Istanbul from the city suggestions.', tr: 'Şehir önerilerinden Istanbul seç.', body: '<label>City<input id="city" aria-label="City" autocomplete="off"></label><div id="suggestions"></div>', code: `city.oninput=()=>{suggestions.replaceChildren();if(city.value){const b=document.createElement('button');b.textContent='Istanbul';b.onclick=()=>{city.value='Istanbul';suggestions.replaceChildren();record(true);status.textContent='Selected: Istanbul'};suggestions.append(b)}}` },
{ id: 'form', en: 'Fill Name Ada, Email [email protected] and City Istanbul, then save the form.', tr: 'Formu Name Ada, Email [email protected] ve City Istanbul ile doldur ve kaydet.', body: '<form id="form"><label>Name<input id="name" aria-label="Name"></label><label>Email<input id="email" aria-label="Email"></label><label>City<input id="city" aria-label="City"></label><button>Save</button></form>', code: `form.onsubmit=e=>{e.preventDefault();const ok=document.querySelector('#name').value==='Ada'&&email.value==='[email protected]'&&city.value==='Istanbul';record(ok);if(ok){form.remove();status.textContent='Record saved: Ada, [email protected], Istanbul'}}` },
{ id: 'save', en: 'Rename the record to WebBrain and save it.', tr: 'Kaydın adını WebBrain yap ve kaydet.', body: '<form id="form"><label>Record name<input id="title" aria-label="Record name" value="Draft"></label><button>Save</button></form>', code: `form.onsubmit=e=>{e.preventDefault();const ok=title.value==='WebBrain';record(ok);if(ok){form.remove();status.textContent='Saved record: WebBrain'}}` },
{ id: 'send', en: 'Send the message "Merhaba" to Ada in the open conversation.', tr: 'Açık konuşmada Ada’ya "Merhaba" mesajını gönder.', body: '<h2>Conversation with Ada</h2><form id="form"><label>Message<textarea id="message" aria-label="Message"></textarea></label><button>Send</button></form><section id="messages"></section>', code: `form.onsubmit=e=>{e.preventDefault();const ok=message.value==='Merhaba';record(ok);if(ok){messages.textContent='You → Ada: Merhaba';message.value='';status.textContent='Message sent to Ada'}}` },
];
export function renderWorkflow(id) {
const w = workflows.find(w => w.id === id); if (!w) throw Error('Unknown workflow');
return `<!doctype html><html lang="en"><meta charset="utf-8"><title>Jev local ${w.id}</title><style>body{font:18px system-ui;max-width:600px;margin:30px}input,select,textarea,button{display:block;font:inherit;padding:8px;margin:12px 0;width:100%;box-sizing:border-box}</style><h1>${w.id}</h1>${w.body}<p id="status" role="status">Ready</p><script>window.fixtureResult={success:false,actions:0,wrong:0};const status=document.querySelector('#status');function record(ok){fixtureResult.actions++;fixtureResult.success=ok;fixtureResult.wrong+=ok?0:1;document.documentElement.dataset.fixtureResult=JSON.stringify(fixtureResult);} ${w.code}</script></html>`;
}
export function benchmarkSchedule() {
return ['chrome', 'firefox'].flatMap(browser => workflows.flatMap(w => Array.from({ length: 5 }, (_, repetition) => ['baseline','jev'].map(variant => ({ browser, workflow: w.id, repetition, variant, locale: repetition % 2 ? 'tr' : 'en', prompt: w[repetition % 2 ? 'tr' : 'en'] }))).flat()));
}
export function summarize(rows) {
const quantile = (values,p) => { const sorted=values.slice().sort((a,b)=>a-b); return sorted.length ? sorted[Math.max(0,Math.ceil(sorted.length*p)-1)] : null; };
const groups = Object.fromEntries(['baseline','jev'].map(variant => {
const data=rows.filter(r=>r.variant===variant); return [variant,{attempts:data.length,successes:data.filter(r=>r.success).length,wrongActions:data.reduce((n,r)=>n+(r.wrong||0),0),duplicateActions:data.reduce((n,r)=>n+(r.duplicates||0),0),p50Ms:quantile(data.map(r=>r.elapsedMs),.5),p95Ms:quantile(data.map(r=>r.elapsedMs),.95),totalMs:data.reduce((n,r)=>n+r.elapsedMs,0),llmCalls:data.reduce((n,r)=>n+(r.llmCalls||0),0),jevCalls:data.reduce((n,r)=>n+(r.jevCalls||0),0),fallbacks:data.reduce((n,r)=>n+(r.fallbacks||0),0),modelCostUsd:data.reduce((n,r)=>n+(r.modelCostUsd||0),0)}];
}));
const improvement=groups.baseline.p50Ms>0?1-groups.jev.p50Ms/groups.baseline.p50Ms:null;
return {...groups,medianImprovement:improvement,meetsTarget:rows.length===120&&improvement>=.25&&groups.jev.successes>=groups.baseline.successes&&groups.jev.wrongActions===0&&groups.jev.duplicateActions===0};
}