utopia-ia/elffuss-code public
Changesets · Branches · Tags · Compare
| Changeset | 71f77de4f55f82f2ef03e3a20ed237be653a3c20e4b5a6ae7eef740824b177a8 |
|---|---|
| Author | KikoCis <kikocisneros@gmail.com> · 2026-10-11 15:12 +02:00 |
| Committer | KikoCis <kikocisneros@gmail.com> · 2026-10-11 15:12 +02:00 |
| Parents | 4b0609511c80 |
7 files changed
added tests/bridge-sums.mjs +27 −0
| @@ -0,0 +1,27 @@ | ||
| 1 | +// web/bridge-dl/SHA256SUMS dice la verdad sobre los binarios que se descargan. | |
| 2 | +// | |
| 3 | +// Ajustes enseña la huella SHA-256 de cada descarga del bridge (sale de este | |
| 4 | +// fichero) para que se pueda comprobar antes de ejecutarlo. Si alguien | |
| 5 | +// recompila los binarios y no regenera SHA256SUMS, la página enseñaría huellas | |
| 6 | +// que no casan: esta prueba lo impide. Para regenerarlo: | |
| 7 | +// cd web/bridge-dl && shasum -a 256 elffuss-bridge-* > SHA256SUMS | |
| 8 | +// | |
| 9 | +// node tests/bridge-sums.mjs | |
| 10 | +import { readFileSync, readdirSync } from 'node:fs'; | |
| 11 | +import { createHash } from 'node:crypto'; | |
| 12 | +import { join, dirname } from 'node:path'; | |
| 13 | +import { fileURLToPath } from 'node:url'; | |
| 14 | +const DIR = join(dirname(fileURLToPath(import.meta.url)), '..', 'web', 'bridge-dl'); | |
| 15 | +let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; }; | |
| 16 | + | |
| 17 | +const binarios = readdirSync(DIR).filter(f => f.startsWith('elffuss-bridge-')).sort(); | |
| 18 | +const lineas = readFileSync(join(DIR, 'SHA256SUMS'), 'utf8').split('\n').filter(Boolean); | |
| 19 | +const sumas = new Map(lineas.map(l => { const m = l.match(/^([0-9a-f]{64})\s+\*?(\S+)$/); return m ? [m[2], m[1]] : [l, null]; })); | |
| 20 | +ok('cada línea de SHA256SUMS tiene el formato de shasum -a 256', [...sumas.values()].every(Boolean), JSON.stringify(lineas.filter(l => !/^[0-9a-f]{64}\s+\S+$/.test(l)))); | |
| 21 | +ok('hay un binario para cada línea, y una línea para cada binario', JSON.stringify([...sumas.keys()].sort()) === JSON.stringify(binarios), JSON.stringify({ binarios, sumas: [...sumas.keys()] })); | |
| 22 | +for (const f of binarios) { | |
| 23 | + const real = createHash('sha256').update(readFileSync(join(DIR, f))).digest('hex'); | |
| 24 | + ok(`la huella de ${f} es la del fichero`, sumas.get(f) === real, sumas.get(f) === real ? real.slice(0, 16) + '…' : `${sumas.get(f)} ≠ ${real}`); | |
| 25 | +} | |
| 26 | +console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ SHA256SUMS casa con los binarios del bridge'); | |
| 27 | +process.exit(fails ? 1 : 0); |
added tests/links.mjs +99 −0
| @@ -0,0 +1,99 @@ | ||
| 1 | +// Enlaces que llevan a un sitio concreto, y de dónde sale lo que se usa. | |
| 2 | +// | |
| 3 | +// 1. #/conv/<id> reabre esa conversación; su menú tiene «Copiar enlace». | |
| 4 | +// 2. #/mind abre la Mente, #/settings Ajustes y #/lab el banco de pruebas. | |
| 5 | +// (Antes solo existía #/file/<ruta>.) | |
| 6 | +// 3. Ajustes enlaza la ficha de cada modelo local (Hugging Face) y la | |
| 7 | +// documentación de la API de cada proveedor externo. | |
| 8 | +// 4. Cada descarga del bridge enseña su SHA-256, el de bridge-dl/SHA256SUMS. | |
| 9 | +// | |
| 10 | +// BASE=http://localhost:8799 node tests/links.mjs | |
| 11 | +import { chromium } from 'playwright'; | |
| 12 | +import { readFileSync } from 'node:fs'; | |
| 13 | +import { join, dirname } from 'node:path'; | |
| 14 | +import { fileURLToPath } from 'node:url'; | |
| 15 | +const BASE = process.env.BASE || 'http://localhost:8799'; | |
| 16 | +const SUMAS = readFileSync(join(dirname(fileURLToPath(import.meta.url)), '..', 'web', 'bridge-dl', 'SHA256SUMS'), 'utf8'); | |
| 17 | +let fails = 0; const ok = (n, c, e = '') => { console.log((c ? '✅' : '❌') + ' ' + n + (e ? ' — ' + e : '')); if (!c) fails++; }; | |
| 18 | + | |
| 19 | +const b = await chromium.launch(); | |
| 20 | +const ctx = await b.newContext({ locale: 'es-ES', permissions: ['clipboard-read', 'clipboard-write'] }); | |
| 21 | +await ctx.addInitScript(() => { | |
| 22 | + try { localStorage.setItem('elffusscode.model', 'rules'); } catch {} | |
| 23 | + try { Object.defineProperty(Navigator.prototype, 'gpu', { get() { return undefined; }, configurable: true }); } catch {} | |
| 24 | +}); | |
| 25 | +const errs = []; | |
| 26 | +const abre = async (ruta = '') => { | |
| 27 | + const p = await ctx.newPage({ viewport: { width: 1400, height: 900 } }); | |
| 28 | + p.on('pageerror', e => errs.push(e.message.slice(0, 160))); | |
| 29 | + await p.goto(BASE + '/?test-opfs' + ruta, { waitUntil: 'domcontentloaded' }); | |
| 30 | + if (ruta !== '#/lab') await p.waitForFunction(() => window.elffussClaw?.conv?.getActive?.(), null, { timeout: 20000 }); | |
| 31 | + return p; | |
| 32 | +}; | |
| 33 | + | |
| 34 | +// 1 · conversaciones | |
| 35 | +let p = await abre(); | |
| 36 | +const ids = await p.evaluate(async () => { | |
| 37 | + const conv = window.elffussClaw.conv; | |
| 38 | + const primera = conv.getActive().id; | |
| 39 | + conv.send(primera, 'hola'); | |
| 40 | + await new Promise(r => setTimeout(r, 600)); | |
| 41 | + const segunda = conv.create().id; | |
| 42 | + return { primera, segunda }; | |
| 43 | +}); | |
| 44 | +// el menú de la pestaña de la primera: «Copiar enlace» | |
| 45 | +await p.locator(`#conv-tabs .tab[data-id="${ids.primera}"]`).click({ button: 'right' }).catch(async () => { | |
| 46 | + await p.locator('#conv-tabs .tab').first().click({ button: 'right' }); | |
| 47 | +}); | |
| 48 | +await p.locator('#conv-menu [role="menuitem"]', { hasText: 'Copiar enlace' }).click(); | |
| 49 | +await p.waitForTimeout(200); | |
| 50 | +const copiado = await p.evaluate(() => navigator.clipboard.readText()).catch(() => ''); | |
| 51 | +ok('1 · «Copiar enlace» copia #/conv/<id> de esa conversación', copiado.endsWith('#/conv/' + ids.primera), copiado); | |
| 52 | +await p.close(); | |
| 53 | +p = await abre('#/conv/' + ids.primera); | |
| 54 | +await p.waitForTimeout(500); | |
| 55 | +const activa = await p.evaluate(() => window.elffussClaw.conv.getActive().id); | |
| 56 | +ok('1 · abrir ese enlace reabre esa conversación', activa === ids.primera, JSON.stringify({ activa, esperada: ids.primera })); | |
| 57 | +await p.close(); | |
| 58 | +p = await abre('#/conv/cnoexiste1234'); | |
| 59 | +await p.waitForTimeout(500); | |
| 60 | +ok('1 · un enlace a una conversación que ya no está lo dice', /ya no está/.test(await p.locator('#statusbar').textContent()), await p.locator('#statusbar').textContent()); | |
| 61 | +await p.close(); | |
| 62 | + | |
| 63 | +// 2 · Mente, Ajustes y Lab | |
| 64 | +p = await abre('#/mind'); | |
| 65 | +await p.waitForTimeout(800); | |
| 66 | +ok('2 · #/mind abre la Mente', await p.evaluate(() => { const o = document.getElementById('mind-overlay'); return !!o && getComputedStyle(o).display !== 'none'; })); | |
| 67 | +await p.close(); | |
| 68 | +p = await abre('#/settings'); | |
| 69 | +await p.waitForTimeout(500); | |
| 70 | +ok('2 · #/settings abre Ajustes', !(await p.locator('#settings-panel').isHidden()) && /Ajustes/.test(await p.locator('#settings-title').textContent())); | |
| 71 | + | |
| 72 | +// 3 · fichas de modelos y documentación de proveedores (con Ajustes abierto) | |
| 73 | +await p.waitForTimeout(500); | |
| 74 | +const enlaces = await p.evaluate(() => ({ | |
| 75 | + fichas: [...document.querySelectorAll('.model-cards-links a')].map(a => ({ t: a.textContent, href: a.href, nombre: a.getAttribute('aria-label') })), | |
| 76 | + docs: [...document.querySelectorAll('#settings-panel .prov-docs')].map(a => ({ href: a.href, nombre: a.getAttribute('aria-label') })), | |
| 77 | +})); | |
| 78 | +ok('3 · Ajustes enlaza la ficha del modelo ligero en Hugging Face', enlaces.fichas.some(f => f.href === 'https://huggingface.co/onnx-community/Qwen3.5-0.8B-ONNX' && /Qwen3\.5-0\.8B/.test(f.nombre)), JSON.stringify(enlaces.fichas)); | |
| 79 | +ok('3 · …y la documentación de la API de cada proveedor externo', enlaces.docs.some(d => /platform\.openai\.com/.test(d.href) && /OpenAI/.test(d.nombre)) && enlaces.docs.some(d => /docs\.anthropic\.com/.test(d.href)) && enlaces.docs.some(d => /ollama/.test(d.href)), JSON.stringify(enlaces.docs)); | |
| 80 | + | |
| 81 | +// 4 · huella SHA-256 de las descargas del bridge | |
| 82 | +await p.waitForSelector('.br-sha', { timeout: 5000 }).catch(() => {}); | |
| 83 | +const huellas = await p.evaluate(() => [...document.querySelectorAll('.br-sha')].map(d => ({ f: d.dataset.file, h: d.querySelector('code')?.textContent }))); | |
| 84 | +const esperado = new Map(SUMAS.split('\n').filter(Boolean).map(l => { const [h, f] = l.split(/\s+/); return [f, h]; })); | |
| 85 | +ok('4 · cada descarga del bridge enseña su SHA-256', huellas.length === esperado.size && huellas.every(x => esperado.get(x.f) === x.h), JSON.stringify(huellas.map(x => x.f))); | |
| 86 | +ok('4 · …y cómo comprobarlo, con el enlace a SHA256SUMS', await p.locator('.br-sha-how a[href="bridge-dl/SHA256SUMS"]').count() === 1); | |
| 87 | +await p.close(); | |
| 88 | + | |
| 89 | +p = await ctx.newPage(); | |
| 90 | +await p.goto(BASE + '/#/lab', { waitUntil: 'domcontentloaded' }); | |
| 91 | +await p.waitForURL(/lab\.html/, { timeout: 10000 }).catch(() => {}); | |
| 92 | +ok('2 · #/lab lleva al banco de pruebas', /lab\.html$/.test(new URL(p.url()).pathname), p.url()); | |
| 93 | +await p.close(); | |
| 94 | + | |
| 95 | +console.log('\n errores JS:', errs[0] || 'ninguno'); | |
| 96 | +ok('sin errores de página', errs.length === 0, errs.join(' | ')); | |
| 97 | +console.log(fails ? `\n❌ ${fails} FALLO(S)` : '\n✅ ENLACES: conversación, Mente, Ajustes y Lab; fichas, docs y huellas'); | |
| 98 | +await b.close(); | |
| 99 | +process.exit(fails ? 1 : 0); |
added web/bridge-dl/SHA256SUMS +5 −0
| @@ -0,0 +1,5 @@ | ||
| 1 | +20178a970327248ddfc67b40f8f44f90f17be683ab85d33c2bc2cb5b1d2a949f elffuss-bridge-linux | |
| 2 | +88c8064b70b2738adbf39d7e208d2365167c4b64a701f318daff79b729e6ea14 elffuss-bridge-linux-arm64 | |
| 3 | +967f0cb58ffb18a29f4a2879a1538d068220c2f2f2af251eabda1ee46883ed2a elffuss-bridge-mac-arm64 | |
| 4 | +d04f453949fba9afe8936e12c09670c29ca60650465d318456115174a3428998 elffuss-bridge-mac-intel | |
| 5 | +d18243496ce6b10f91af9fcec4fe9900a611195cecbff92255e2374aae141d0e elffuss-bridge-windows.exe |
modified web/css/code.css +2 −0
| @@ -221,6 +221,8 @@ | ||
| 221 | 221 | .bridge-card #br-token, .bridge-card #br-folder { background: var(--bg); border: 1px solid var(--line); color: var(--fg); border-radius: 6px; padding: 6px 9px; font-size: .78rem; width: 100%; } |
| 222 | 222 | .bridge-card details { color: var(--muted); } |
| 223 | 223 | .bridge-card details summary::marker { color: var(--accent2); } |
| 224 | +.bridge-card .br-sha { font-size: .64rem; color: var(--muted); margin: 0 0 6px; overflow-wrap: anywhere; } | |
| 225 | +.bridge-card .br-sha code { font-size: .64rem; color: var(--fg); } | |
| 224 | 226 | #fireworks-fx { position: fixed; inset: 0; z-index: 999; pointer-events: none; } |
| 225 | 227 | .cfg-notif-btn { background: #3fb970; border: none; color: #06180d; border-radius: 6px; padding: 3px 10px; font-size: .68rem; font-weight: 700; cursor: pointer; } |
| 226 | 228 | #mind-cfg label { font-size: .68rem; color: #b9a7ff; margin-top: 4px; } |
modified web/js/i18n.js +8 −0
| @@ -74,6 +74,7 @@ | ||
| 74 | 74 | wsDownload: "Descargar copia", |
| 75 | 75 | wsWhat: "Qué hay guardado", |
| 76 | 76 | setTitle: "Ajustes", |
| 77 | + setModelCards: 'Fichas de los modelos:', setModelCardFor: 'Ficha de {name} en Hugging Face', | |
| 77 | 78 | close: "cerrar", |
| 78 | 79 | setBrainTitle: "Cerebro (modelo)", |
| 79 | 80 | setModelE4bSub: "El mejor · WebGPU local · ~2.8 GB", |
| @@ -126,6 +127,7 @@ | ||
| 126 | 127 | termCapsNoBridge: "shell del proyecto · node/npm/python → Bridge local (⚙ Ajustes)", |
| 127 | 128 | setBridgeFolderLabel: "Carpeta de trabajo (opcional — si no, la carpeta desde la que arrancaste el bridge; fuera de ella no ejecuta nada)", |
| 128 | 129 | setBridgeDesc: "Un pequeño programa que TÚ ejecutas en tu ordenador — le da a la elfa ejecución real (node, npm, python…) sin salir de tu máquina. Nada se instala en el navegador.", |
| 130 | + setBridgeShaHow: 'Para comprobar la descarga: shasum -a 256 -c, con el fichero', | |
| 129 | 131 | setBridgeDownload: "⬇ Descargar para {os}", |
| 130 | 132 | setBridgeOtherOS: "otro sistema operativo", |
| 131 | 133 | setBridgeOld: "¿Ya tenías un bridge y ahora no conecta? Descárgalo otra vez (versión 1.1.2): los anteriores a la 1.1.1 no aceptan la dirección nueva de Elffuss Code.", |
| @@ -199,6 +201,7 @@ | ||
| 199 | 201 | setPermLabel: "Escribir y editar ficheros sin pedir confirmación", |
| 200 | 202 | setPermNote: "Esto controla solo la escritura de ficheros (code.write / code.edit): desmárcalo si prefieres revisar cada cambio antes de aplicarlo. Los comandos del terminal (terminal.run) se ejecutan siempre sin preguntar.", |
| 201 | 203 | provToggle: "Activar {name}", setModelLoadingCard: "cargando…", |
| 204 | + provDocs: 'documentación ↗', provDocsFor: 'Documentación de la API de {name}', | |
| 202 | 205 | modelDot: "Modelo: {name} · {state} — clic para cambiarlo", modelDotBasic: "Modo básico, sin modelo de IA — clic para elegir uno", |
| 203 | 206 | modelState_off: "sin cargar", modelState_loading: "cargando…", modelState_on: "listo", modelState_error: "no se pudo cargar", |
| 204 | 207 | // teclado, menús y pestañas |
| @@ -209,6 +212,7 @@ | ||
| 209 | 212 | goalPlaceholder: "🎯 Describe el objetivo: lo descompongo en tareas y las hago una a una…", |
| 210 | 213 | convTabs: "Conversaciones abiertas", convBusy: "trabajando", tabCloseNamed: "Cerrar la pestaña «{title}» (no borra la conversación)", |
| 211 | 214 | convRename: "Renombrar…", convRenamePrompt: "Nombre de la conversación (vacío = el automático):", |
| 215 | + convCopyLink: 'Copiar enlace', convLinkCopied: '🔗 Enlace a la conversación copiado', convLinkMissing: 'Esa conversación ya no está en este navegador.', | |
| 212 | 216 | histDelNamed: "Eliminar para siempre «{title}»", |
| 213 | 217 | palSearchHint: "Escribe al menos 2 letras para buscar dentro del código", |
| 214 | 218 | termResizeLabel: "Altura del terminal (↑/↓)", |
| @@ -309,6 +313,7 @@ | ||
| 309 | 313 | wsDownload: "Download copy", |
| 310 | 314 | wsWhat: "What's stored", |
| 311 | 315 | setTitle: "Settings", |
| 316 | + setModelCards: 'Model cards:', setModelCardFor: '{name} model card on Hugging Face', | |
| 312 | 317 | close: "close", |
| 313 | 318 | setBrainTitle: "Brain (model)", |
| 314 | 319 | setModelE4bSub: "The best · local WebGPU · ~2.8 GB", |
| @@ -361,6 +366,7 @@ | ||
| 361 | 366 | termCapsNoBridge: "project shell · node/npm/python → Local bridge (⚙ Settings)", |
| 362 | 367 | setBridgeFolderLabel: "Working folder (optional — otherwise the folder you started the bridge from; it runs nothing outside it)", |
| 363 | 368 | setBridgeDesc: "A small program that YOU run on your computer — it gives the elf real execution (node, npm, python…) without leaving your machine. Nothing is installed in the browser.", |
| 369 | + setBridgeShaHow: 'To check the download: shasum -a 256 -c, with the file', | |
| 364 | 370 | setBridgeDownload: "⬇ Download for {os}", |
| 365 | 371 | setBridgeOtherOS: "another operating system", |
| 366 | 372 | setBridgeOld: "Already had a bridge and now it won't connect? Download it again (version 1.1.2): versions before 1.1.1 don't accept Elffuss Code's new address.", |
| @@ -434,6 +440,7 @@ | ||
| 434 | 440 | setPermLabel: "Write and edit files without asking", |
| 435 | 441 | setPermNote: "This only controls writing files (code.write / code.edit): untick it if you prefer to review each change before it is applied. Terminal commands (terminal.run) always run without asking.", |
| 436 | 442 | provToggle: "Turn on {name}", setModelLoadingCard: "loading…", |
| 443 | + provDocs: 'docs ↗', provDocsFor: '{name} API documentation', | |
| 437 | 444 | modelDot: "Model: {name} · {state} — click to change it", modelDotBasic: "Basic mode, no AI model — click to pick one", |
| 438 | 445 | modelState_off: "not loaded", modelState_loading: "loading…", modelState_on: "ready", modelState_error: "couldn't load", |
| 439 | 446 | // keyboard, menus and tabs |
| @@ -444,6 +451,7 @@ | ||
| 444 | 451 | goalPlaceholder: "🎯 Describe the goal: I'll break it into tasks and do them one by one…", |
| 445 | 452 | convTabs: "Open conversations", convBusy: "working", tabCloseNamed: "Close the “{title}” tab (doesn't delete the conversation)", |
| 446 | 453 | convRename: "Rename…", convRenamePrompt: "Conversation name (empty = automatic):", |
| 454 | + convCopyLink: 'Copy link', convLinkCopied: '🔗 Link to the conversation copied', convLinkMissing: 'That conversation is no longer in this browser.', | |
| 447 | 455 | histDelNamed: "Delete “{title}” forever", |
| 448 | 456 | palSearchHint: "Type at least 2 letters to search inside the code", |
| 449 | 457 | termResizeLabel: "Terminal height (↑/↓)", |
modified web/js/main.js +100 −9
| @@ -121,15 +121,26 @@ | ||
| 121 | 121 | el.replaceChildren(enlaceFichero(m[1], m[2], txt)); |
| 122 | 122 | }); |
| 123 | 123 | } |
| 124 | -// #/file/ruta[:línea] abre ese fichero: lo usan los enlaces de arriba (abrir | |
| 125 | -// en otra pestaña) y sirve para volver al mismo sitio tras recargar. | |
| 124 | +// Enlaces a un sitio del IDE, para volver a él o pasárselo a alguien: | |
| 125 | +// #/file/ruta[:línea] ese fichero (los enlaces del chat, abrir en otra pestaña) | |
| 126 | +// #/conv/<id> esa conversación (su menú tiene «Copiar enlace») | |
| 127 | +// #/mind la Mente | |
| 128 | +// #/settings Ajustes | |
| 129 | +// #/lab el banco de pruebas (lab.html) | |
| 130 | +// Antes solo existía #/file; lo demás no tenía forma de enlazarse. | |
| 126 | 131 | function abreDesdeHash() { |
| 127 | 132 | let h = location.hash; |
| 128 | 133 | try { h = decodeURI(h); } catch { /* — */ } |
| 134 | + if (h === '#/lab') { location.replace('lab.html'); return; } | |
| 135 | + if (!codeTools.handle()) return; | |
| 129 | 136 | const m = h.match(/^#\/file\/(.+?)(?::(\d+))?$/); |
| 130 | - if (!m || !codeTools.handle()) return; | |
| 131 | - openFile(m[1]).then(() => { if (m[2]) gotoLine(+m[2]); }); | |
| 132 | -} | |
| 137 | + if (m) { openFile(m[1]).then(() => { if (m[2]) gotoLine(+m[2]); }); return; } | |
| 138 | + const c = h.match(/^#\/conv\/([\w-]{4,40})$/); | |
| 139 | + if (c) { conv.open(c[1]).then(r => { if (!r) $('statusbar').textContent = t('convLinkMissing'); }); return; } | |
| 140 | + if (h === '#/mind') { mind.openMind(); return; } | |
| 141 | + if (h === '#/settings') { renderSettings(); return; } | |
| 142 | +} | |
| 143 | +const enlaceA = ruta => location.origin + location.pathname + '#/' + ruta; | |
| 133 | 144 | addEventListener('hashchange', abreDesdeHash); |
| 134 | 145 | |
| 135 | 146 | // Todo lo que pinta el chat entra por aquí. Lo que se escribió mientras la elfa |
| @@ -471,6 +482,12 @@ | ||
| 471 | 482 | }], |
| 472 | 483 | [t('tmClose'), () => conv.closeTab(c.id)], |
| 473 | 484 | [t('tmCloseOthers'), () => { for (const o of conv.getOpenTabs()) if (o.id !== c.id) conv.closeTab(o.id); conv.switchTo(c.id); }], |
| 485 | + // Un enlace que reabre ESTA conversación (#/conv/<id>), para volver a ella. | |
| 486 | + [t('convCopyLink'), async () => { | |
| 487 | + const url = enlaceA('conv/' + c.id); | |
| 488 | + try { await navigator.clipboard.writeText(url); $('statusbar').textContent = t('convLinkCopied'); } | |
| 489 | + catch { prompt(t('convCopyLink'), url); } | |
| 490 | + }], | |
| 474 | 491 | ]; |
| 475 | 492 | for (const [label, fn] of opciones) { |
| 476 | 493 | const b = document.createElement('button'); |
| @@ -980,10 +997,33 @@ | ||
| 980 | 997 | if (/Linux/.test(ua)) return [arch === 'arm' || /aarch64|arm64/i.test(ua) ? 'elffuss-bridge-linux-arm64' : 'elffuss-bridge-linux']; |
| 981 | 998 | return ['elffuss-bridge-mac-arm64', 'elffuss-bridge-mac-intel']; |
| 982 | 999 | } |
| 1000 | +// La huella SHA-256 de cada descarga, de bridge-dl/SHA256SUMS (el formato de | |
| 1001 | +// `shasum -a 256`): un programa que se ejecuta en tu máquina tiene que poder | |
| 1002 | +// comprobarse antes de abrirlo, y la página solo daba el tamaño. | |
| 1003 | +let sumasBridge = null; | |
| 1004 | +async function huellasBridge() { | |
| 1005 | + if (sumasBridge) return sumasBridge; | |
| 1006 | + const m = new Map(); | |
| 1007 | + try { | |
| 1008 | + const r = await fetch('bridge-dl/SHA256SUMS', { cache: 'no-store' }); | |
| 1009 | + if (r.ok) for (const linea of (await r.text()).split('\n')) { const x = linea.match(/^([0-9a-f]{64})\s+\*?(\S+)$/); if (x) m.set(x[2], x[1]); } | |
| 1010 | + } catch { /* sin huellas: se enseña lo demás */ } | |
| 1011 | + return (sumasBridge = m); | |
| 1012 | +} | |
| 983 | 1013 | async function pintaDescargasBridge(card, NOMBRES) { |
| 984 | - const principales = await bridgeParaEstaMaquina(); | |
| 1014 | + const [principales, sumas] = await Promise.all([bridgeParaEstaMaquina(), huellasBridge()]); | |
| 985 | 1015 | const host = card.querySelector('#br-dl'), otros = card.querySelector('#br-dl-other'); |
| 986 | 1016 | if (!host || !otros) return; |
| 1017 | + const huella = f => { | |
| 1018 | + if (!sumas.has(f)) return null; | |
| 1019 | + const d = document.createElement('div'); | |
| 1020 | + d.className = 'br-sha'; | |
| 1021 | + d.dataset.file = f; | |
| 1022 | + d.append('SHA-256 '); | |
| 1023 | + const c = document.createElement('code'); c.textContent = sumas.get(f); | |
| 1024 | + d.appendChild(c); | |
| 1025 | + return d; | |
| 1026 | + }; | |
| 987 | 1027 | const enlace = (f, principal) => { |
| 988 | 1028 | const a = document.createElement('a'); |
| 989 | 1029 | a.href = 'bridge-dl/' + f; a.setAttribute('download', ''); |
| @@ -997,8 +1037,19 @@ | ||
| 997 | 1037 | }).catch(() => {}); |
| 998 | 1038 | return a; |
| 999 | 1039 | }; |
| 1000 | - host.replaceChildren(...principales.map(f => enlace(f, true))); | |
| 1001 | - otros.replaceChildren(...Object.keys(NOMBRES).filter(f => !principales.includes(f)).map(f => { const d = document.createElement('div'); d.appendChild(enlace(f, false)); return d; })); | |
| 1040 | + host.replaceChildren(...principales.flatMap(f => [enlace(f, true), huella(f)].filter(Boolean))); | |
| 1041 | + otros.replaceChildren(...Object.keys(NOMBRES).filter(f => !principales.includes(f)).map(f => { const d = document.createElement('div'); d.appendChild(enlace(f, false)); const h = huella(f); if (h) d.appendChild(h); return d; })); | |
| 1042 | + card.querySelector('.br-sha-how')?.remove(); | |
| 1043 | + if (sumas.size) { | |
| 1044 | + const como = document.createElement('p'); | |
| 1045 | + como.className = 'muted br-sha-how'; | |
| 1046 | + como.style.cssText = 'font-size:.68rem;margin:4px 0 0'; | |
| 1047 | + const a = document.createElement('a'); | |
| 1048 | + a.href = 'bridge-dl/SHA256SUMS'; a.target = '_blank'; a.rel = 'noopener'; a.textContent = 'SHA256SUMS'; | |
| 1049 | + a.style.color = 'var(--accent2)'; | |
| 1050 | + como.append(t('setBridgeShaHow') + ' ', a); | |
| 1051 | + host.after(como); // fuera de la lista de descargas: es cómo comprobarlas | |
| 1052 | + } | |
| 1002 | 1053 | } |
| 1003 | 1054 | |
| 1004 | 1055 | // pequeño estallido de fuegos artificiales (canvas, un par de segundos) para |
| @@ -1096,6 +1147,13 @@ | ||
| 1096 | 1147 | } |
| 1097 | 1148 | repintaTarjetasModelo = () => { for (const [card, m] of tarjetas) if (card.isConnected) pintaTarjeta(card, m); }; |
| 1098 | 1149 | box.appendChild(grid); |
| 1150 | + // De dónde sale cada modelo: su ficha en Hugging Face. Los enlaces salen de | |
| 1151 | + // los registros de los proveedores (las URLs de los pesos), no de una lista | |
| 1152 | + // aparte que se quedaría vieja. | |
| 1153 | + const fichas = el('p', 'muted model-cards-links'); | |
| 1154 | + fichas.style.cssText = 'font-size:.7rem;margin:6px 0 0'; | |
| 1155 | + box.appendChild(fichas); | |
| 1156 | + pintaFichasModelo(fichas, LOCAL); | |
| 1099 | 1157 | |
| 1100 | 1158 | // --- Espacio de trabajo: guardar conversaciones/skills en disco --- |
| 1101 | 1159 | box.append(el('div', 'sk-h', '💾 ' + t('wsTitle'))); |
| @@ -1331,7 +1389,16 @@ | ||
| 1331 | 1389 | const use = el('button', 'prov-use', t("setProvUse")); |
| 1332 | 1390 | use.hidden = !c.enabled || activeModel === 'ext:' + id; |
| 1333 | 1391 | use.onclick = () => { changeModel('ext:' + id); renderSettings(); }; |
| 1334 | - head.append(toggle, title, use); | |
| 1392 | + head.append(toggle, title); | |
| 1393 | + // La documentación de la API de ese proveedor (qué modelos hay, qué clave). | |
| 1394 | + if (c.docs) { | |
| 1395 | + const docs = el('a', 'prov-docs', t('provDocs')); | |
| 1396 | + docs.href = c.docs; docs.target = '_blank'; docs.rel = 'noopener noreferrer'; | |
| 1397 | + docs.setAttribute('aria-label', t('provDocsFor', { name: c.label })); | |
| 1398 | + docs.style.cssText = 'color:var(--accent2);font-size:.7rem;margin-left:8px'; | |
| 1399 | + head.appendChild(docs); | |
| 1400 | + } | |
| 1401 | + head.appendChild(use); | |
| 1335 | 1402 | const fields = el('div', 'prov-fields' + (c.enabled ? '' : ' hide')); |
| 1336 | 1403 | const model = document.createElement('input'); model.value = c.model || ''; model.placeholder = t('setModelPh'); |
| 1337 | 1404 | const key = document.createElement('input'); key.type = 'password'; key.value = c.apiKey || ''; |
| @@ -1354,6 +1421,28 @@ | ||
| 1354 | 1421 | skBtn.onclick = openSkillsPanel; |
| 1355 | 1422 | box.appendChild(skBtn); |
| 1356 | 1423 | } |
| 1424 | +async function pintaFichasModelo(nodo, locales) { | |
| 1425 | + let lt = null, mc = null; | |
| 1426 | + try { [lt, mc] = await Promise.all([import('./providers/litert.js'), import('./model-config.js')]); } catch { return; } | |
| 1427 | + const enlaces = []; | |
| 1428 | + for (const m of locales) { | |
| 1429 | + let url = null; | |
| 1430 | + if (m.id.startsWith('litert:')) { const u = lt.MODELS?.[m.id.slice(7)]?.url; if (u) url = u.split('/resolve/')[0]; } | |
| 1431 | + else if (m.id.startsWith('onnx:')) { const o = mc.ONNX_MODELS?.[m.id.slice(5)]; if (o?.id && !o.selfHosted) url = 'https://huggingface.co/' + o.id; } | |
| 1432 | + if (url) enlaces.push([m.name, url]); | |
| 1433 | + } | |
| 1434 | + if (!enlaces.length || !nodo.isConnected) return; | |
| 1435 | + nodo.append(t('setModelCards') + ' '); | |
| 1436 | + enlaces.forEach(([nombre, url], i) => { | |
| 1437 | + const a = document.createElement('a'); | |
| 1438 | + a.href = url; a.target = '_blank'; a.rel = 'noopener noreferrer'; | |
| 1439 | + a.textContent = nombre + ' ↗'; | |
| 1440 | + a.style.color = 'var(--accent2)'; | |
| 1441 | + a.setAttribute('aria-label', t('setModelCardFor', { name: nombre })); | |
| 1442 | + if (i) nodo.append(' · '); | |
| 1443 | + nodo.append(a); | |
| 1444 | + }); | |
| 1445 | +} | |
| 1357 | 1446 | function labeled(label, input) { |
| 1358 | 1447 | const w = el('label', 'field'); w.append(el('span', 'muted', label), input); return w; |
| 1359 | 1448 | } |
| @@ -1420,6 +1509,8 @@ | ||
| 1420 | 1509 | } |
| 1421 | 1510 | |
| 1422 | 1511 | async function boot() { |
| 1512 | + // #/lab no necesita proyecto: es otra página. | |
| 1513 | + if (location.hash === '#/lab') { location.replace('lab.html'); return; } | |
| 1423 | 1514 | applyI18n(); // localiza el chrome estático (placeholder) antes de pintar nada |
| 1424 | 1515 | // Caché de modelos (persistente + service worker) ANTES de descargar nada, |
| 1425 | 1516 | // para que hasta la primera descarga de pesos quede cacheada y no se repita. |
modified web/js/settings.js +3 −0
| @@ -9,16 +9,19 @@ | ||
| 9 | 9 | openai: { |
| 10 | 10 | kind: 'openai', label: 'OpenAI', enabled: false, |
| 11 | 11 | baseURL: 'https://api.openai.com/v1', model: 'gpt-4o-mini', apiKey: '', |
| 12 | + docs: 'https://platform.openai.com/docs/api-reference/chat', | |
| 12 | 13 | help: 'Tu clave sk-… Se queda en tu navegador. OpenAI permite llamadas directas (CORS).', |
| 13 | 14 | }, |
| 14 | 15 | anthropic: { |
| 15 | 16 | kind: 'anthropic', label: 'Anthropic (Claude)', enabled: false, |
| 16 | 17 | baseURL: 'https://api.anthropic.com', model: 'claude-sonnet-5', apiKey: '', |
| 18 | + docs: 'https://docs.anthropic.com/en/api/messages', | |
| 17 | 19 | help: 'Tu clave sk-ant-… Se envía la cabecera de acceso directo desde navegador.', |
| 18 | 20 | }, |
| 19 | 21 | ollama: { |
| 20 | 22 | kind: 'openai', label: 'Ollama (local)', enabled: false, |
| 21 | 23 | baseURL: 'http://localhost:11434/v1', model: 'llama3.2', apiKey: 'ollama', |
| 24 | + docs: 'https://github.com/ollama/ollama/blob/main/docs/openai.md', | |
| 22 | 25 | help: 'Ollama en tu máquina. Arráncalo con OLLAMA_ORIGINS=* para permitir el navegador.', |
| 23 | 26 | }, |
| 24 | 27 | server: { |