openvibers/openvibe.exchange Commits
Search: the compare tool first, engines named, no false Free (#214)
Changes
@@@ -327,16 +327,40 @@/* ── /search: engines by kind, the try form as a card, results side by side ── */.xs { padding-block: 32px 48px; display: grid; gap: 22px; }--.xs-group h2, .xs-try h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 1.12rem; }++.xs-list h2, .xs-try h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 1.12rem; }++.xs-group h3 { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ovk-muted); }++.xs-group:first-of-type h3 { margin-top: 0; }.xs-engines { list-style: none; margin: 0; padding: 0; border: 1px solid var(--ovk-line); border-radius: var(--ov-radius-2, 16px); background: var(--ovk-panel); overflow: hidden; }--.xs-engine { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 12px; padding: 12px 16px; border-top: 1px solid var(--ovk-line); }++.xs-engine { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 12px; padding: 10px 14px 10px 16px; border-top: 1px solid var(--ovk-line); }.xs-engine:first-child { border-top: 0; }.xs-engine.is-off { color: var(--ovk-muted); }.xs-engine-main { display: grid; gap: 2px; min-width: 0; }.xs-engine-main span { color: var(--ovk-muted); font-size: .86rem; }.xs-engine-price { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }.xs-try { padding: 18px; border: 1px solid var(--ovk-line); border-radius: var(--ov-radius-2, 16px); background: var(--ovk-panel); }--.xs-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; align-items: end; }++/* The compare tool (Opus, 2026-11-11): the box and its button on one line, the kind as a segmented switch, the two++ engines side by side with "vs" between, and the picture filters in one fold. */++.xs-form { display: grid; gap: 14px; }++.xs-q { display: flex; gap: 8px; min-width: 0; }++.xs-q input { flex: 1; min-width: 0; min-height: 48px; box-sizing: border-box; padding: 10px 14px; border: 1px solid var(--ovk-line); border-radius: 12px; background: var(--ovk-bg, transparent); color: var(--ovk-text); font: inherit; }++.xs-q input:focus-visible { outline: 2px solid var(--ovk-accent); outline-offset: 1px; }++.xs-q .ovk-btn { min-height: 48px; flex: none; }++.xs-kinds { display: inline-flex; justify-self: start; gap: 4px; margin: 0; padding: 4px; border: 1px solid var(--ovk-line); border-radius: 999px; background: var(--ovk-panel-2); min-width: 0; }++.xs-kinds label { position: relative; display: inline-flex; }++.xs-kinds input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }++.xs-kinds span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 16px; border-radius: 999px; font-size: .9rem; color: var(--ovk-muted); }++.xs-kinds input:checked + span { background: color-mix(in srgb, var(--ovk-accent) 20%, transparent); color: var(--ovk-text); font-weight: 650; }++.xs-kinds input:focus-visible + span { outline: 2px solid var(--ovk-accent); outline-offset: 1px; }++.xs-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 10px; }++.xs-vs { padding-bottom: 12px; color: var(--ovk-muted); font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }++.xs-more { border: 1px solid var(--ovk-line); border-radius: 12px; }++.xs-more > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 40px 0 14px; position: relative; cursor: pointer; list-style: none; font-weight: 600; font-size: .92rem; }++.xs-more > summary::-webkit-details-marker { display: none; }++.xs-more > summary small { margin-left: auto; color: var(--ovk-muted); font-weight: 400; font-size: .82rem; }++.xs-more > summary::after { content: ""; position: absolute; right: 16px; top: 50%; width: 7px; height: 7px; margin-top: -5px; border-right: 2px solid var(--ovk-muted); border-bottom: 2px solid var(--ovk-muted); transform: rotate(45deg); transition: transform .18s ease; }++.xs-more[open] > summary::after { transform: rotate(-135deg); margin-top: -1px; }++.xs-more-body { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; padding: 4px 14px 14px; }++.xs-list { display: grid; gap: 0; }.xs-field { display: grid; gap: 6px; min-width: 0; }.xs-field > span { font-weight: 600; font-size: .9rem; }.xs-field--wide { grid-column: 1 / -1; }@@@ -348,12 +372,25 @@.xs-result ol { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 8px; }.xs-result li p { margin: 2px 0 0; color: var(--ovk-muted); font-size: .86rem; overflow-wrap: anywhere; }.xs-receipt, .xs-note { margin: 0; color: var(--ovk-muted); font-size: .86rem; }++/* A result: its title as a link in the accent, the snippet under it, a picture's thumbnail rounded, and "Source and++ usage" as a small fold. */++.xs-result li > a { color: var(--ovk-text); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }++.xs-result li > a:hover { color: var(--ovk-accent); text-decoration: underline; }++.xs-result li > img { display: block; max-width: 100%; height: auto; margin-top: 6px; border-radius: 8px; background: var(--ovk-panel); }++.xs-result details { margin-top: 2px; }++.xs-result details > summary { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; list-style: none; color: var(--ovk-muted); font-size: .82rem; }++.xs-result details > summary::-webkit-details-marker { display: none; }++.xs-result details > summary::before { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s ease; }++.xs-result details[open] > summary::before { transform: rotate(45deg); }++.xs-result details p a { color: var(--ovk-accent); }@media (max-width: 760px) {.xs { padding-block: 20px 36px; }.xs-engine { grid-template-columns: minmax(0, 1fr) auto; }.xs-engine > .ovk-badge { grid-column: 2; }-- .xs-form, .xs-results { grid-template-columns: minmax(0, 1fr); }++ .xs-results { grid-template-columns: minmax(0, 1fr); }.xs-try { padding: 14px; }++ .xs-more-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }++ .xs-more-body > :last-child { grid-column: 1 / -1; }}/* Grid children never stretch the page for a long line (the head's subtitle widened /search to 514 px on a phone). */.xs > * { min-width: 0; }@@@ -365,3 +402,10 @@.xpr-list span { color: var(--ovk-muted); font-size: .92rem; }.xpr-note { margin: 12px 2px 0; color: var(--ovk-muted); font-size: .88rem; }@media (min-width: 760px) { .xpr-list li { grid-template-columns: minmax(200px, 1fr) 2fr; align-items: baseline; gap: 16px; } }++@media (max-width: 520px) {++ .xs-pair { grid-template-columns: minmax(0, 1fr); gap: 10px; }++ .xs-vs { display: none; }++ .xs-q .ovk-btn > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }++ .xs-q .ovk-btn { width: 48px; padding: 0; justify-content: center; }++}++@media (prefers-reduced-motion: reduce) { .xs-more > summary::after { transition: none; } }@@@ -1,13 +1,15 @@'use strict';/**-- * /search (Opus, 11-09): the engines AI has, grouped by what they find (web, pictures, icons), each with what it is,-- * its price per 1,000 searches and whether it works now; then "Try two engines" side by side. The engine list is-- * AI's own (GET /api/v1/exchange/search/engines), so a new engine shows here the day AI adds it.++ * /search (Opus, 11-09; the tool first 11-11): "Compare two engines" at the top (what to search for, the kind as a++ * switch, the two engines side by side, the picture filters in one fold), the results under it, then the engines AI++ * has, grouped by what they find (web, pictures, icons), each with what it is, its price per 1,000 searches and whether++ * it works now. The engine list is AI's own (GET /api/v1/exchange/search/engines), so a new engine shows here the day++ * AI adds it, named from its id until this list knows it.*/const kit = require('openvibe-shared/kit');const { esc } = require('../render/html');--// What each engine is, in a line; an engine AI adds before this list knows it shows its id and no line.++// What each engine is, in a line.const ENGINES = {openvibe: ['OpenVibe Search', "OpenVibe's own index of the network's pages."],searxng: ['SearXNG', 'Many search engines at once, through our own instance.'],@@@ -16,27 +18,34 @@ const ENGINES = {iconify: ['Iconify', 'Open icon sets, as SVG with their licence.'],deepseek: ['DeepSeek Search', 'Web search with fetched page text.'],brave: ['Brave Search', 'An independent web index.'],++ 'brave-images': ['Brave Images', "Pictures from Brave's independent index."],exa: ['Exa', 'Search by meaning, built for agents.'],tavily: ['Tavily', 'Web search shaped for AI answers.'],serper: ['Serper', "Google's results, fast."],++ 'serper-images': ['Serper Images', 'Google Images results, fast.'],serpapi: ['SerpAPI', "Google's results with every feature."],jina: ['Jina', 'Search and a reader that cleans pages.'],perplexity: ['Perplexity Sonar', 'An answer with its sources.'],kagi: ['Kagi', 'A paid index without ads.'],google: ['Google Programmable Search', 'Google, in a site-scoped engine.'],++ meta: ['Meta AI search', 'A Muse Spark answer with the web pages it read.'],++ 'openvibe-egress': ['OpenVibe Fetch', 'Reads one page you name, through OpenVibe.'],unsplash: ['Unsplash', 'Free photographs.'],pexels: ['Pexels', 'Free photographs and videos.'],pixabay: ['Pixabay', 'Free pictures and illustrations.'],};const KINDS = [['web', 'Web'], ['images', 'Pictures'], ['icons', 'Icons']];--const nameOf = (e) => (ENGINES[e.id] || [e.id])[0];--const price = (e) => (!Number(e.price_per_1000) ? 'Free' : `$${Number(e.price_per_1000).toLocaleString('en-US', { maximumFractionDigits: 3 })} per 1,000`);++const titled = (id) => String(id || '').split(/[-_]/).filter(Boolean).map((w) => w[0].toUpperCase() + w.slice(1)).join(' ');++const nameOf = (e) => (ENGINES[e.id] || [titled(e.id)])[0];++// A missing price is not free: an engine billed per token says so instead of claiming "Free".++const price = (e) => (e.price_per_1000 == null || !Number.isFinite(Number(e.price_per_1000)) ? 'Priced per call'++ : !Number(e.price_per_1000) ? 'Free' : `$${Number(e.price_per_1000).toLocaleString('en-US', { maximumFractionDigits: 3 })} per 1,000`);const state = (e) => (e.available === false ? kit.badge(e.byok ? 'Your key' : 'Not set up yet') : e.healthy === false ? kit.badge('Resting', 'warn') : kit.badge('Ready', 'ok'));function engineRow(e) {const line = (ENGINES[e.id] || [])[1];return `<li class="xs-engine${e.available === false ? ' is-off' : ''}"><div class="xs-engine-main"><strong>${esc(nameOf(e))}</strong>${line ? `<span>${esc(line)}</span>` : ''}</div>`-- + `<span class="xs-engine-price">${esc(price(e))}</span>${state(e)}</li>`;++ + `<span class="xs-engine-price"${e.pricing_note ? ` title="${esc(e.pricing_note)}"` : ''}>${esc(price(e))}</span>${state(e)}</li>`;}function results(list) {@@@ -49,22 +58,33 @@ function results(list) {function searchPage({ engines = [], found = [], query = {} } = {}) {const groups = KINDS.map(([kind, label]) => {const rows = engines.filter((e) => Array.isArray(e.kinds) && e.kinds.includes(kind));-- return rows.length ? `<section class="xs-group"><h2>${esc(label)}<span class="ovk-count">${rows.length}</span></h2><ul class="xs-engines">${rows.map(engineRow).join('')}</ul></section>` : '';++ return rows.length ? `<section class="xs-group"><h3>${esc(label)}<span class="ovk-count">${rows.length}</span></h3><ul class="xs-engines">${rows.map(engineRow).join('')}</ul></section>` : '';}).join('');-- const options = engines.map((e) => `<option value="${esc(e.id)}">${esc(nameOf(e))}</option>`).join('');-- const pick = (field, label, i) => `<label class="xs-field"><span>${label}</span><select name="${field}">${engines.map((e, j) => `<option value="${esc(e.id)}"${j === i ? ' selected' : ''}>${esc(nameOf(e))}</option>`).join('') || options}</select></label>`;++ const kind = KINDS.some(([k]) => k === query.kind) ? query.kind : 'web';++ // The engines in each list grouped by what they find; the first two that work are picked unless the search named some.++ const ready = engines.filter((e) => e.available !== false);++ const defaults = [query.first || (ready[0] || engines[0] || {}).id, query.second || (ready[1] || engines[1] || {}).id];++ const pick = (field, label, chosen) => `<label class="xs-field"><span>${label}</span><select name="${field}">${KINDS.map(([k, l]) => {++ const rows = engines.filter((e) => (Array.isArray(e.kinds) ? e.kinds[0] === k : k === 'web'));++ return rows.length ? `<optgroup label="${esc(l)}">${rows.map((e) => `<option value="${esc(e.id)}"${e.id === chosen ? ' selected' : ''}>${esc(nameOf(e))}${e.available === false ? ' (needs a key)' : ''}</option>`).join('')}</optgroup>` : '';++ }).join('')}</select></label>`;++ const sel = (name, label, values) => `<label class="xs-field"><span>${label}</span><select name="${name}"><option value="">Any</option>${values.map((v) => `<option value="${v}"${query[name] === v ? ' selected' : ''}>${v.replace(/_/g, ' ')}</option>`).join('')}</select></label>`;++ const set = ['size', 'color', 'type', 'license', 'after'].filter((k) => query[k]).length;++ const filters = `<details class="xs-more"${set ? ' open' : ''}><summary>Picture filters${set ? `<span class="ovk-count">${set}</span>` : ''}<small>for Pictures</small></summary><div class="xs-more-body">`++ + sel('size', 'Size', ['small', 'medium', 'large'])++ + sel('color', 'Colour', ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'black_and_white'])++ + sel('type', 'Type', ['photo', 'illustration', 'vector'])++ + `<label class="xs-field"><span>Licence</span><input name="license" value="${esc(query.license || '')}" placeholder="cc0"></label>`++ + `<label class="xs-field"><span>After</span><input name="after" type="date" value="${esc(query.after || '')}"></label></div></details>`;++ const kinds = `<fieldset class="xs-kinds"><legend class="ex-sr">What to find</legend>${KINDS.map(([k, l]) => `<label><input type="radio" name="kind" value="${k}"${k === kind ? ' checked' : ''}><span>${l}</span></label>`).join('')}</fieldset>`;return `<div class="ex-wrap xs">${kit.head({ title: 'Search', sub: 'Web, pictures and icons from many engines, with the same key as your models.' })}`-- + (groups || '<p class="xs-note">The engine list is not reachable right now.</p>')-- + `<section class="xs-try"><h2>Try two engines</h2><form method="post" action="/search" class="xs-form">`-- + `<label class="xs-field xs-field--wide"><span>Search for</span><input name="q" required maxlength="500" placeholder="open source live streaming" value="${esc(query.q || '')}"></label>`-- + `<label class="xs-field"><span>Kind</span><select name="kind">${KINDS.map(([k, l]) => `<option value="${k}"${query.kind === k ? ' selected' : ''}>${l}</option>`).join('')}</select></label>`-- + `<label class="xs-field"><span>Size</span><select name="size"><option value="">Any</option>${['small', 'medium', 'large'].map((v) => `<option value="${v}"${query.size === v ? ' selected' : ''}>${v}</option>`).join('')}</select></label>`-- + `<label class="xs-field"><span>Color</span><select name="color"><option value="">Any</option>${['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'black_and_white'].map((v) => `<option value="${v}"${query.color === v ? ' selected' : ''}>${v.replace('_', ' ')}</option>`).join('')}</select></label>`-- + `<label class="xs-field"><span>Type</span><select name="type"><option value="">Any</option>${['photo', 'illustration', 'vector'].map((v) => `<option value="${v}"${query.type === v ? ' selected' : ''}>${v}</option>`).join('')}</select></label>`-- + `<label class="xs-field"><span>License</span><input name="license" value="${esc(query.license || '')}" placeholder="cc0"></label>`-- + `<label class="xs-field"><span>After</span><input name="after" type="date" value="${esc(query.after || '')}"></label>`-- + `${pick('first', 'First engine', 0)}${pick('second', 'Second engine', 1)}`-- + `<p class="xs-go">${kit.button({ label: 'Compare', type: 'submit' })}</p></form>${results(found)}</section>`++ + `<section class="xs-try" aria-labelledby="xs-try-h"><h2 id="xs-try-h">Compare two engines</h2><form method="post" action="/search" class="xs-form">`++ + `<div class="xs-q"><input name="q" required maxlength="500" placeholder="What are you looking for?" value="${esc(query.q || '')}" aria-label="Search for">`++ + `${kit.button({ label: 'Compare', type: 'submit', icon: 'search' })}</div>`++ + `${kinds}<div class="xs-pair">${pick('first', 'First engine', defaults[0])}<span class="xs-vs" aria-hidden="true">vs</span>${pick('second', 'Second engine', defaults[1])}</div>`++ + `${filters}</form>${results(found)}</section>`++ + `<section class="xs-list" aria-labelledby="xs-list-h"><h2 id="xs-list-h">The engines<span class="ovk-count">${engines.length}</span></h2>`++ + (groups || '<p class="xs-note">The engine list is not reachable right now.</p>') + '</section>'+ `<p class="xs-note">Pictures come with their licence and author: keep the attribution line with each one. With your own engine key a search costs the engine's price and nothing more.</p></div>`;}
@@ -327,16 +327,40 @@
@@ -327,16 +327,40 @@
/* ── /search: engines by kind, the try form as a card, results side by side ── */
/* ── /search: engines by kind, the try form as a card, results side by side ── */
.xs { padding-block: 32px 48px; display: grid; gap: 22px; }
.xs { padding-block: 32px 48px; display: grid; gap: 22px; }
-.xs-group h2, .xs-try h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 10px; font-size: 1.12rem; }
+.xs-list h2, .xs-try h2 { display: flex; align-items: center; gap: 8px; margin: 0 0 12px; font-size: 1.12rem; }
+.xs-group h3 { display: flex; align-items: center; gap: 8px; margin: 14px 0 8px; font-size: .8rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ovk-muted); }
+.xs-group:first-of-type h3 { margin-top: 0; }
.xs-engines { list-style: none; margin: 0; padding: 0; border: 1px solid var(--ovk-line); border-radius: var(--ov-radius-2, 16px); background: var(--ovk-panel); overflow: hidden; }
.xs-engines { list-style: none; margin: 0; padding: 0; border: 1px solid var(--ovk-line); border-radius: var(--ov-radius-2, 16px); background: var(--ovk-panel); overflow: hidden; }
-.xs-engine { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 12px; padding: 12px 16px; border-top: 1px solid var(--ovk-line); }
+.xs-engine { display: grid; grid-template-columns: minmax(0, 1fr) auto auto; align-items: center; gap: 4px 12px; padding: 10px 14px 10px 16px; border-top: 1px solid var(--ovk-line); }
.xs-engine:first-child { border-top: 0; }
.xs-engine:first-child { border-top: 0; }
.xs-engine.is-off { color: var(--ovk-muted); }
.xs-engine.is-off { color: var(--ovk-muted); }
.xs-engine-main { display: grid; gap: 2px; min-width: 0; }
.xs-engine-main { display: grid; gap: 2px; min-width: 0; }
.xs-engine-main span { color: var(--ovk-muted); font-size: .86rem; }
.xs-engine-main span { color: var(--ovk-muted); font-size: .86rem; }
.xs-engine-price { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.xs-engine-price { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
.xs-try { padding: 18px; border: 1px solid var(--ovk-line); border-radius: var(--ov-radius-2, 16px); background: var(--ovk-panel); }
.xs-try { padding: 18px; border: 1px solid var(--ovk-line); border-radius: var(--ov-radius-2, 16px); background: var(--ovk-panel); }
-.xs-form { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px 14px; align-items: end; }
+/* The compare tool (Opus, 2026-11-11): the box and its button on one line, the kind as a segmented switch, the two
+ engines side by side with "vs" between, and the picture filters in one fold. */
+.xs-form { display: grid; gap: 14px; }
+.xs-q { display: flex; gap: 8px; min-width: 0; }
+.xs-q input { flex: 1; min-width: 0; min-height: 48px; box-sizing: border-box; padding: 10px 14px; border: 1px solid var(--ovk-line); border-radius: 12px; background: var(--ovk-bg, transparent); color: var(--ovk-text); font: inherit; }
+.xs-q input:focus-visible { outline: 2px solid var(--ovk-accent); outline-offset: 1px; }
+.xs-q .ovk-btn { min-height: 48px; flex: none; }
+.xs-kinds { display: inline-flex; justify-self: start; gap: 4px; margin: 0; padding: 4px; border: 1px solid var(--ovk-line); border-radius: 999px; background: var(--ovk-panel-2); min-width: 0; }
+.xs-kinds label { position: relative; display: inline-flex; }
+.xs-kinds input { position: absolute; inset: 0; opacity: 0; margin: 0; cursor: pointer; }
+.xs-kinds span { display: inline-flex; align-items: center; min-height: 36px; padding: 0 16px; border-radius: 999px; font-size: .9rem; color: var(--ovk-muted); }
+.xs-kinds input:checked + span { background: color-mix(in srgb, var(--ovk-accent) 20%, transparent); color: var(--ovk-text); font-weight: 650; }
+.xs-kinds input:focus-visible + span { outline: 2px solid var(--ovk-accent); outline-offset: 1px; }
+.xs-pair { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: end; gap: 10px; }
+.xs-vs { padding-bottom: 12px; color: var(--ovk-muted); font-size: .82rem; font-weight: 700; text-transform: uppercase; letter-spacing: .06em; }
+.xs-more { border: 1px solid var(--ovk-line); border-radius: 12px; }
+.xs-more > summary { display: flex; align-items: center; gap: 8px; min-height: 44px; padding: 0 40px 0 14px; position: relative; cursor: pointer; list-style: none; font-weight: 600; font-size: .92rem; }
+.xs-more > summary::-webkit-details-marker { display: none; }
+.xs-more > summary small { margin-left: auto; color: var(--ovk-muted); font-weight: 400; font-size: .82rem; }
+.xs-more > summary::after { content: ""; position: absolute; right: 16px; top: 50%; width: 7px; height: 7px; margin-top: -5px; border-right: 2px solid var(--ovk-muted); border-bottom: 2px solid var(--ovk-muted); transform: rotate(45deg); transition: transform .18s ease; }
+.xs-more[open] > summary::after { transform: rotate(-135deg); margin-top: -1px; }
+.xs-more-body { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px 12px; padding: 4px 14px 14px; }
+.xs-list { display: grid; gap: 0; }
.xs-field { display: grid; gap: 6px; min-width: 0; }
.xs-field { display: grid; gap: 6px; min-width: 0; }
.xs-field > span { font-weight: 600; font-size: .9rem; }
.xs-field > span { font-weight: 600; font-size: .9rem; }
.xs-field--wide { grid-column: 1 / -1; }
.xs-field--wide { grid-column: 1 / -1; }
@@ -348,12 +372,25 @@
@@ -348,12 +372,25 @@
.xs-result ol { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 8px; }
.xs-result ol { margin: 8px 0 0; padding-left: 18px; display: grid; gap: 8px; }
.xs-result li p { margin: 2px 0 0; color: var(--ovk-muted); font-size: .86rem; overflow-wrap: anywhere; }
.xs-result li p { margin: 2px 0 0; color: var(--ovk-muted); font-size: .86rem; overflow-wrap: anywhere; }
.xs-receipt, .xs-note { margin: 0; color: var(--ovk-muted); font-size: .86rem; }
.xs-receipt, .xs-note { margin: 0; color: var(--ovk-muted); font-size: .86rem; }
+/* A result: its title as a link in the accent, the snippet under it, a picture's thumbnail rounded, and "Source and
+ usage" as a small fold. */
+.xs-result li > a { color: var(--ovk-text); font-weight: 600; text-decoration: none; overflow-wrap: anywhere; }
+.xs-result li > a:hover { color: var(--ovk-accent); text-decoration: underline; }
+.xs-result li > img { display: block; max-width: 100%; height: auto; margin-top: 6px; border-radius: 8px; background: var(--ovk-panel); }
+.xs-result details { margin-top: 2px; }
+.xs-result details > summary { display: inline-flex; align-items: center; gap: 6px; min-height: 32px; cursor: pointer; list-style: none; color: var(--ovk-muted); font-size: .82rem; }
+.xs-result details > summary::-webkit-details-marker { display: none; }
+.xs-result details > summary::before { content: ""; width: 6px; height: 6px; border-right: 2px solid currentColor; border-bottom: 2px solid currentColor; transform: rotate(-45deg); transition: transform .15s ease; }
+.xs-result details[open] > summary::before { transform: rotate(45deg); }
+.xs-result details p a { color: var(--ovk-accent); }
@media (max-width: 760px) {
@media (max-width: 760px) {
.xs { padding-block: 20px 36px; }
.xs { padding-block: 20px 36px; }
.xs-engine { grid-template-columns: minmax(0, 1fr) auto; }
.xs-engine { grid-template-columns: minmax(0, 1fr) auto; }
.xs-engine > .ovk-badge { grid-column: 2; }
.xs-engine > .ovk-badge { grid-column: 2; }
- .xs-form, .xs-results { grid-template-columns: minmax(0, 1fr); }
+ .xs-results { grid-template-columns: minmax(0, 1fr); }
.xs-try { padding: 14px; }
.xs-try { padding: 14px; }
+ .xs-more-body { grid-template-columns: repeat(2, minmax(0, 1fr)); }
+ .xs-more-body > :last-child { grid-column: 1 / -1; }
}
}
/* Grid children never stretch the page for a long line (the head's subtitle widened /search to 514 px on a phone). */
/* Grid children never stretch the page for a long line (the head's subtitle widened /search to 514 px on a phone). */
.xs > * { min-width: 0; }
.xs > * { min-width: 0; }
@@ -365,3 +402,10 @@
@@ -365,3 +402,10 @@
.xpr-list span { color: var(--ovk-muted); font-size: .92rem; }
.xpr-list span { color: var(--ovk-muted); font-size: .92rem; }
.xpr-note { margin: 12px 2px 0; color: var(--ovk-muted); font-size: .88rem; }
.xpr-note { margin: 12px 2px 0; color: var(--ovk-muted); font-size: .88rem; }
@media (min-width: 760px) { .xpr-list li { grid-template-columns: minmax(200px, 1fr) 2fr; align-items: baseline; gap: 16px; } }
@media (min-width: 760px) { .xpr-list li { grid-template-columns: minmax(200px, 1fr) 2fr; align-items: baseline; gap: 16px; } }
+@media (max-width: 520px) {
+ .xs-pair { grid-template-columns: minmax(0, 1fr); gap: 10px; }
+ .xs-vs { display: none; }
+ .xs-q .ovk-btn > span { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
+ .xs-q .ovk-btn { width: 48px; padding: 0; justify-content: center; }
+}
+@media (prefers-reduced-motion: reduce) { .xs-more > summary::after { transition: none; } }
@@ -1,13 +1,15 @@
@@ -1,13 +1,15 @@
'use strict';
'use strict';
/**
/**
- * /search (Opus, 11-09): the engines AI has, grouped by what they find (web, pictures, icons), each with what it is,
- * its price per 1,000 searches and whether it works now; then "Try two engines" side by side. The engine list is
- * AI's own (GET /api/v1/exchange/search/engines), so a new engine shows here the day AI adds it.
+ * /search (Opus, 11-09; the tool first 11-11): "Compare two engines" at the top (what to search for, the kind as a
+ * switch, the two engines side by side, the picture filters in one fold), the results under it, then the engines AI
+ * has, grouped by what they find (web, pictures, icons), each with what it is, its price per 1,000 searches and whether
+ * it works now. The engine list is AI's own (GET /api/v1/exchange/search/engines), so a new engine shows here the day
+ * AI adds it, named from its id until this list knows it.
*/
*/
const kit = require('openvibe-shared/kit');
const kit = require('openvibe-shared/kit');
const { esc } = require('../render/html');
const { esc } = require('../render/html');
-// What each engine is, in a line; an engine AI adds before this list knows it shows its id and no line.
+// What each engine is, in a line.
const ENGINES = {
const ENGINES = {
openvibe: ['OpenVibe Search', "OpenVibe's own index of the network's pages."],
openvibe: ['OpenVibe Search', "OpenVibe's own index of the network's pages."],
searxng: ['SearXNG', 'Many search engines at once, through our own instance.'],
searxng: ['SearXNG', 'Many search engines at once, through our own instance.'],
@@ -16,27 +18,34 @@ const ENGINES = {
@@ -16,27 +18,34 @@ const ENGINES = {
iconify: ['Iconify', 'Open icon sets, as SVG with their licence.'],
iconify: ['Iconify', 'Open icon sets, as SVG with their licence.'],
deepseek: ['DeepSeek Search', 'Web search with fetched page text.'],
deepseek: ['DeepSeek Search', 'Web search with fetched page text.'],
brave: ['Brave Search', 'An independent web index.'],
brave: ['Brave Search', 'An independent web index.'],
+ 'brave-images': ['Brave Images', "Pictures from Brave's independent index."],
exa: ['Exa', 'Search by meaning, built for agents.'],
exa: ['Exa', 'Search by meaning, built for agents.'],
tavily: ['Tavily', 'Web search shaped for AI answers.'],
tavily: ['Tavily', 'Web search shaped for AI answers.'],
serper: ['Serper', "Google's results, fast."],
serper: ['Serper', "Google's results, fast."],
+ 'serper-images': ['Serper Images', 'Google Images results, fast.'],
serpapi: ['SerpAPI', "Google's results with every feature."],
serpapi: ['SerpAPI', "Google's results with every feature."],
jina: ['Jina', 'Search and a reader that cleans pages.'],
jina: ['Jina', 'Search and a reader that cleans pages.'],
perplexity: ['Perplexity Sonar', 'An answer with its sources.'],
perplexity: ['Perplexity Sonar', 'An answer with its sources.'],
kagi: ['Kagi', 'A paid index without ads.'],
kagi: ['Kagi', 'A paid index without ads.'],
google: ['Google Programmable Search', 'Google, in a site-scoped engine.'],
google: ['Google Programmable Search', 'Google, in a site-scoped engine.'],
+ meta: ['Meta AI search', 'A Muse Spark answer with the web pages it read.'],
+ 'openvibe-egress': ['OpenVibe Fetch', 'Reads one page you name, through OpenVibe.'],
unsplash: ['Unsplash', 'Free photographs.'],
unsplash: ['Unsplash', 'Free photographs.'],
pexels: ['Pexels', 'Free photographs and videos.'],
pexels: ['Pexels', 'Free photographs and videos.'],
pixabay: ['Pixabay', 'Free pictures and illustrations.'],
pixabay: ['Pixabay', 'Free pictures and illustrations.'],
};
};
const KINDS = [['web', 'Web'], ['images', 'Pictures'], ['icons', 'Icons']];
const KINDS = [['web', 'Web'], ['images', 'Pictures'], ['icons', 'Icons']];
-const nameOf = (e) => (ENGINES[e.id] || [e.id])[0];
-const price = (e) => (!Number(e.price_per_1000) ? 'Free' : `$${Number(e.price_per_1000).toLocaleString('en-US', { maximumFractionDigits: 3 })} per 1,000`);
+const titled = (id) => String(id || '').split(/[-_]/).filter(Boolean).map((w) => w[0].toUpperCase() + w.slice(1)).join(' ');
+const nameOf = (e) => (ENGINES[e.id] || [titled(e.id)])[0];
+// A missing price is not free: an engine billed per token says so instead of claiming "Free".
+const price = (e) => (e.price_per_1000 == null || !Number.isFinite(Number(e.price_per_1000)) ? 'Priced per call'
+ : !Number(e.price_per_1000) ? 'Free' : `$${Number(e.price_per_1000).toLocaleString('en-US', { maximumFractionDigits: 3 })} per 1,000`);
const state = (e) => (e.available === false ? kit.badge(e.byok ? 'Your key' : 'Not set up yet') : e.healthy === false ? kit.badge('Resting', 'warn') : kit.badge('Ready', 'ok'));
const state = (e) => (e.available === false ? kit.badge(e.byok ? 'Your key' : 'Not set up yet') : e.healthy === false ? kit.badge('Resting', 'warn') : kit.badge('Ready', 'ok'));
function engineRow(e) {
function engineRow(e) {
const line = (ENGINES[e.id] || [])[1];
const line = (ENGINES[e.id] || [])[1];
return `<li class="xs-engine${e.available === false ? ' is-off' : ''}"><div class="xs-engine-main"><strong>${esc(nameOf(e))}</strong>${line ? `<span>${esc(line)}</span>` : ''}</div>`
return `<li class="xs-engine${e.available === false ? ' is-off' : ''}"><div class="xs-engine-main"><strong>${esc(nameOf(e))}</strong>${line ? `<span>${esc(line)}</span>` : ''}</div>`
- + `<span class="xs-engine-price">${esc(price(e))}</span>${state(e)}</li>`;
+ + `<span class="xs-engine-price"${e.pricing_note ? ` title="${esc(e.pricing_note)}"` : ''}>${esc(price(e))}</span>${state(e)}</li>`;
}
}
function results(list) {
function results(list) {
@@ -49,22 +58,33 @@ function results(list) {
@@ -49,22 +58,33 @@ function results(list) {
function searchPage({ engines = [], found = [], query = {} } = {}) {
function searchPage({ engines = [], found = [], query = {} } = {}) {
const groups = KINDS.map(([kind, label]) => {
const groups = KINDS.map(([kind, label]) => {
const rows = engines.filter((e) => Array.isArray(e.kinds) && e.kinds.includes(kind));
const rows = engines.filter((e) => Array.isArray(e.kinds) && e.kinds.includes(kind));
- return rows.length ? `<section class="xs-group"><h2>${esc(label)}<span class="ovk-count">${rows.length}</span></h2><ul class="xs-engines">${rows.map(engineRow).join('')}</ul></section>` : '';
+ return rows.length ? `<section class="xs-group"><h3>${esc(label)}<span class="ovk-count">${rows.length}</span></h3><ul class="xs-engines">${rows.map(engineRow).join('')}</ul></section>` : '';
}).join('');
}).join('');
- const options = engines.map((e) => `<option value="${esc(e.id)}">${esc(nameOf(e))}</option>`).join('');
- const pick = (field, label, i) => `<label class="xs-field"><span>${label}</span><select name="${field}">${engines.map((e, j) => `<option value="${esc(e.id)}"${j === i ? ' selected' : ''}>${esc(nameOf(e))}</option>`).join('') || options}</select></label>`;
+ const kind = KINDS.some(([k]) => k === query.kind) ? query.kind : 'web';
+ // The engines in each list grouped by what they find; the first two that work are picked unless the search named some.
+ const ready = engines.filter((e) => e.available !== false);
+ const defaults = [query.first || (ready[0] || engines[0] || {}).id, query.second || (ready[1] || engines[1] || {}).id];
+ const pick = (field, label, chosen) => `<label class="xs-field"><span>${label}</span><select name="${field}">${KINDS.map(([k, l]) => {
+ const rows = engines.filter((e) => (Array.isArray(e.kinds) ? e.kinds[0] === k : k === 'web'));
+ return rows.length ? `<optgroup label="${esc(l)}">${rows.map((e) => `<option value="${esc(e.id)}"${e.id === chosen ? ' selected' : ''}>${esc(nameOf(e))}${e.available === false ? ' (needs a key)' : ''}</option>`).join('')}</optgroup>` : '';
+ }).join('')}</select></label>`;
+ const sel = (name, label, values) => `<label class="xs-field"><span>${label}</span><select name="${name}"><option value="">Any</option>${values.map((v) => `<option value="${v}"${query[name] === v ? ' selected' : ''}>${v.replace(/_/g, ' ')}</option>`).join('')}</select></label>`;
+ const set = ['size', 'color', 'type', 'license', 'after'].filter((k) => query[k]).length;
+ const filters = `<details class="xs-more"${set ? ' open' : ''}><summary>Picture filters${set ? `<span class="ovk-count">${set}</span>` : ''}<small>for Pictures</small></summary><div class="xs-more-body">`
+ + sel('size', 'Size', ['small', 'medium', 'large'])
+ + sel('color', 'Colour', ['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'black_and_white'])
+ + sel('type', 'Type', ['photo', 'illustration', 'vector'])
+ + `<label class="xs-field"><span>Licence</span><input name="license" value="${esc(query.license || '')}" placeholder="cc0"></label>`
+ + `<label class="xs-field"><span>After</span><input name="after" type="date" value="${esc(query.after || '')}"></label></div></details>`;
+ const kinds = `<fieldset class="xs-kinds"><legend class="ex-sr">What to find</legend>${KINDS.map(([k, l]) => `<label><input type="radio" name="kind" value="${k}"${k === kind ? ' checked' : ''}><span>${l}</span></label>`).join('')}</fieldset>`;
return `<div class="ex-wrap xs">${kit.head({ title: 'Search', sub: 'Web, pictures and icons from many engines, with the same key as your models.' })}`
return `<div class="ex-wrap xs">${kit.head({ title: 'Search', sub: 'Web, pictures and icons from many engines, with the same key as your models.' })}`
- + (groups || '<p class="xs-note">The engine list is not reachable right now.</p>')
- + `<section class="xs-try"><h2>Try two engines</h2><form method="post" action="/search" class="xs-form">`
- + `<label class="xs-field xs-field--wide"><span>Search for</span><input name="q" required maxlength="500" placeholder="open source live streaming" value="${esc(query.q || '')}"></label>`
- + `<label class="xs-field"><span>Kind</span><select name="kind">${KINDS.map(([k, l]) => `<option value="${k}"${query.kind === k ? ' selected' : ''}>${l}</option>`).join('')}</select></label>`
- + `<label class="xs-field"><span>Size</span><select name="size"><option value="">Any</option>${['small', 'medium', 'large'].map((v) => `<option value="${v}"${query.size === v ? ' selected' : ''}>${v}</option>`).join('')}</select></label>`
- + `<label class="xs-field"><span>Color</span><select name="color"><option value="">Any</option>${['red', 'orange', 'yellow', 'green', 'blue', 'purple', 'black_and_white'].map((v) => `<option value="${v}"${query.color === v ? ' selected' : ''}>${v.replace('_', ' ')}</option>`).join('')}</select></label>`
- + `<label class="xs-field"><span>Type</span><select name="type"><option value="">Any</option>${['photo', 'illustration', 'vector'].map((v) => `<option value="${v}"${query.type === v ? ' selected' : ''}>${v}</option>`).join('')}</select></label>`
- + `<label class="xs-field"><span>License</span><input name="license" value="${esc(query.license || '')}" placeholder="cc0"></label>`
- + `<label class="xs-field"><span>After</span><input name="after" type="date" value="${esc(query.after || '')}"></label>`
- + `${pick('first', 'First engine', 0)}${pick('second', 'Second engine', 1)}`
- + `<p class="xs-go">${kit.button({ label: 'Compare', type: 'submit' })}</p></form>${results(found)}</section>`
+ + `<section class="xs-try" aria-labelledby="xs-try-h"><h2 id="xs-try-h">Compare two engines</h2><form method="post" action="/search" class="xs-form">`
+ + `<div class="xs-q"><input name="q" required maxlength="500" placeholder="What are you looking for?" value="${esc(query.q || '')}" aria-label="Search for">`
+ + `${kit.button({ label: 'Compare', type: 'submit', icon: 'search' })}</div>`
+ + `${kinds}<div class="xs-pair">${pick('first', 'First engine', defaults[0])}<span class="xs-vs" aria-hidden="true">vs</span>${pick('second', 'Second engine', defaults[1])}</div>`
+ + `${filters}</form>${results(found)}</section>`
+ + `<section class="xs-list" aria-labelledby="xs-list-h"><h2 id="xs-list-h">The engines<span class="ovk-count">${engines.length}</span></h2>`
+ + (groups || '<p class="xs-note">The engine list is not reachable right now.</p>') + '</section>'
+ `<p class="xs-note">Pictures come with their licence and author: keep the attribution line with each one. With your own engine key a search costs the engine's price and nothing more.</p></div>`;
+ `<p class="xs-note">Pictures come with their licence and author: keep the attribution line with each one. With your own engine key a search costs the engine's price and nothing more.</p></div>`;
}
}