Skip to content

~95% on SimpleQA (e.g. Qwen3.6-27B on a 3090). Supports all local and cloud LLMs (llama.cpp, Ollama, Google, ...). 10+ search engines - arXiv, PubMed, your private documents. Everything Local & Encrypted.

2.0 KB
Raw Blame
/** Select an engine CI can submit under the guarded egress policy. */
async function selectPublicArxivEngine(page, timeout = 20000) {
    await page.waitForSelector('#policy_egress_scope', { timeout });
    const currentScope = await page.$eval('#policy_egress_scope', (el) => el.value);
    if (currentScope !== 'public_only') {
        const responsePromise = page.waitForResponse((response) => {
            if (response.request().method() !== 'GET') return false;
            const url = new URL(response.url());
            return url.pathname.endsWith('/settings/api/available-search-engines') &&
                url.searchParams.get('egress_scope') === 'public_only';
        }, { timeout });
        await page.select('#policy_egress_scope', 'public_only');
        const response = await responsePromise;
        if (!response.ok()) throw new Error(`Public engine list returned HTTP ${response.status()}`);
    }

    await page.waitForFunction(
        () => !document.getElementById('search_engine')?.parentNode?.classList.contains('ldr-loading'),
        { timeout },
    );

    const selector = '#search-engine-dropdown-list [data-value="arxiv"]';
    const deadline = Date.now() + timeout;
    while (Date.now() < deadline) {
        await page.click('#search_engine');
        const ready = await page.waitForFunction((query) => {
            const option = document.querySelector(query);
            return option && !option.classList.contains('ldr-custom-dropdown-item--disabled');
        }, { timeout: 1000 }, selector).then(() => true).catch(() => false);
        if (ready) break;
    }
    const option = await page.$(selector);
    if (!option || !(await option.evaluate((el) => !el.classList.contains('ldr-custom-dropdown-item--disabled')))) {
        throw new Error('arxiv was not selectable under Public only scope');
    }
    await option.click();
    await page.waitForFunction(
        () => document.getElementById('search_engine_hidden')?.value === 'arxiv',
        { timeout },
    );
}

module.exports = { selectPublicArxivEngine };