retire-provenance: superseded Q b/ objects (sha256 CAS, HOLO-LEAN-RESOLVER P1.3)
Browse filesFiles changed (4)
- sha256/0c8428aa060ee191f5552ea4663929918e752eb243bb70c416c61a29101523b9Added
- sha256/2cc65275ca0cca65fc77a47bfd7cf1ce6e79d9b1fedb22f9eada6a6b31dfcab3Added+1
- sha256/3f1449137aa9b623734ecbd90e436b7467908eece30d18ab1fa7c548642c8938Added
- sha256/85be07b7411283d43c035f9c98980ff63f76bd9e12df153d75e7712efaae2f3aAdded+460
1{"@context":["https://www.w3.org/ns/did/v1","https://w3id.org/security/data-integrity/v2",{"dcterms":"http://purl.org/dc/terms/","links":{"@container":"@set","@id":"schema:hasPart"},"prov":"http://www.w3.org/ns/prov#","rel":"schema:additionalType","schema":"https://schema.org/"},{"holstr":"https://hologram.os/ns/strand#"}],"@type":["prov:Entity","holstr:Entry"],"holstr:kind":"release","holstr:op":"did:holo:sha256:87599792c7b13fad9d6c57d3b89d2cef35e4715869f5cde597ab60ca92699f0b","holstr:payload":{"apps":{"bonsai":"85be07b7411283d43c035f9c98980ff63f76bd9e12df153d75e7712efaae2f3a","carry":"9f44164b17e6b7e37f39623bb445d49b6608da5f2b04cef8b1a8b183362a6b9a","hello":"66c1ada5ac08a2d4f73851bbe7458ad5fb6e2226c5a131c3829abfe715900fed","holo-messenger":"01e2db1e847e73881b7ce6f251677a4c0f9629203d0bc913053ffb4047b1df2d","jellyfin":"3fd2a00105ad0e8f01109dce52ff4c7a0cc6c9444532b0453ed9d770cce2d3a4","resolve":"23aec66382775f5773693615338f37c37a5f58257ec95aece33a664baa6fe0db","yourspace":"9ffc94e11c78fbe6b940bc04ac92f0f12238cf7ce82b5092c53d5761146a50df"},"boot":{"entry":"holo-portal.mjs","sha256":"caeb3e57b6eeab09bee6d67c022145a8e2dae610c929a7f51bc169898625e7e8"},"closure":"bfe9ffbd79c1690f716f6c58267da9ba8208fe385e69fa6616ddae86e98e2bb5","manifest":"792736ddc9a6fa4d6ad612ac0bf851834e7acc46ba3ea335c6f0e32fdf24bda6","runtime":{"apps/q/pkg/holospaces_web.js":"b9f8a887de588c5193dc65ca9ce206a70c6df53595b848e0ce0299c2d88a5753","apps/q/pkg/holospaces_web_bg.wasm":"9d90b4ea8bccee8c239073c7ec7dd5158c6d11f1f668487570d17475d79e661e","apps/workspace/pkg/holospaces_web.js":"8c30aa5582dffe4548d27fa7863163eba689ed65126be472c003f5884fc8e534","usr/lib/holo/holowhat/holospaces_web.js":"a5b5d9c559a1d2812c33e9d7a4b1c24bb03059482503a23356e4c9c32d4d8b88","usr/lib/holo/holowhat/holospaces_web_bg.wasm":"00cfa4960b319ba1ba7291cddb20dea130a407ce8b42426218854f4f68f4dcd7","usr/lib/pkg/holospaces_web.js":"8c30aa5582dffe4548d27fa7863163eba689ed65126be472c003f5884fc8e534","usr/lib/pkg/holospaces_web_bg.wasm":"3370b22070b56218a57df6406e2e4ba7cc171e942d4d1f2ae4297ea2c4c08d9c"},"shell":"0e8ac9d7dd55694dcc30ce1cdcb688a2b624ba54eb90619bdf7251d123ba17b5","world":"03e1a6c7ac7c4d30df0cca0716304a0d6a4c3e3ca20eb98ddfa74bc247877556"},"holstr:prev":"did:holo:sha256:8142f24fab68c4c184914817fd2177b323e7e8690f69a5bc65f5a21957a37f62","holstr:seq":389,"prov:generatedAtTime":"2026-07-15T21:01:40.573Z"}123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460<!doctype html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1">
<title>Bonsai</title>
<style>
/* Claude-desktop look: warm charcoal stage, 11% hairlines, 12-14px radii, serif display, coral accent.
Type floor is 15px everywhere. Everything fits ONE viewport at 1280Γ800 AND 375Γ812 (dvh + clamp). */
:root { --bg:#262624; --ink:#eceae4; --muted:#b8b5ad; --faint:rgba(232,230,224,.45);
--hair:rgba(255,255,255,.11); --coral:#d97757; --coral-hi:#e8987a; --lav:#c4b5fd; --r:13px;
--serif:"Tiempos Text","Charter","Iowan Old Style",Georgia,serif; }
* { box-sizing:border-box; margin:0; padding:0; }
html,body { height:100%; }
body { background:var(--bg); color:var(--ink); font:15px/1.55 system-ui,-apple-system,"Segoe UI",Inter,sans-serif;
-webkit-font-smoothing:antialiased; overflow:hidden; }
.num { font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace; font-size:15px; }
.stage { position:fixed; inset:0; height:100dvh; display:flex; flex-direction:column; align-items:center;
justify-content:center; padding:24px; opacity:0; pointer-events:none; transition:opacity .6s ease; }
.stage.on { opacity:1; pointer-events:auto; }
/* ββ arrival: full-bleed hologram canvas behind left-aligned copy ββ */
#arrive { flex-direction:row; align-items:center; justify-content:flex-start; padding:0; }
#holo { position:absolute; inset:0; width:100%; height:100%; display:block; }
#arrive .copy { position:relative; z-index:1; max-width:620px; padding:0 clamp(24px,6vw,96px); }
#arrive h1 { font-family:var(--serif); font-weight:500; font-size:clamp(40px,7vw,84px); line-height:1.06;
letter-spacing:-.015em; text-wrap:balance; }
#arrive .sub { margin-top:22px; font-size:clamp(18px,1.6vw,20px); line-height:1.5; color:var(--muted); max-width:46ch; }
#arrive button { margin-top:34px; background:var(--coral); border:none; color:#faf9f5; border-radius:999px;
padding:16px 34px; font:500 17px/1 system-ui,sans-serif; cursor:pointer;
transition:transform .2s ease, filter .2s ease; }
#arrive button:hover { filter:brightness(1.08); transform:translateY(-1px); }
#arrive button:disabled { filter:saturate(.3) brightness(.8); cursor:default; transform:none; }
#arrive .fine { margin-top:16px; font-size:15px; color:var(--faint); }
@media (max-width:760px) { /* stacked: hologram floats in the upper half, copy anchors low */
#arrive { align-items:flex-end; }
#arrive .copy { padding-bottom:max(44px, env(safe-area-inset-bottom, 0px) + 36px); }
}
/* ββ chat: the Claude-desktop room β serif greeting, ONE centered input card, quiet metrics ββ */
#chat { justify-content:center; padding:0; }
#chat .col { display:flex; flex-direction:column; width:min(100%,760px); height:100%; padding:0 22px; justify-content:center; }
#chat .col.started { justify-content:flex-start; }
#hello { text-align:center; margin-bottom:26px; }
#hello .mark { display:inline-block; width:30px; height:30px; vertical-align:-4px; margin-right:12px; color:var(--coral); }
#hello h2 { display:inline; font-family:var(--serif); font-weight:500; font-size:clamp(30px,4.4vw,44px); letter-spacing:-.01em; }
.col.started #hello { display:none; }
#log { display:none; }
.col.started #log { display:block; flex:1; overflow-y:auto; padding:30px 4px 16px;
scrollbar-width:none; -ms-overflow-style:none; } /* the content scrolls; no chrome */
#log::-webkit-scrollbar { width:0; height:0; }
.msg { margin:0 0 20px; }
.msg .who { font-size:15px; color:var(--faint); margin-bottom:4px; }
.msg.user .who { color:var(--muted); }
.msg .body { white-space:pre-wrap; font-size:16px; line-height:1.6; }
details.think { margin:0 0 8px; border-left:2px solid var(--hair); padding-left:10px; }
details.think summary { list-style:none; cursor:pointer; font-size:15px; color:var(--faint); }
details.think summary::-webkit-details-marker { display:none; }
details.think .t { color:var(--faint); font-size:15px; white-space:pre-wrap; margin-top:4px; }
.note { text-align:center; font-size:15px; color:var(--faint); margin:6px 0 12px; }
#card { background:rgba(255,255,255,.03); border:1px solid var(--hair); border-radius:18px; padding:6px 8px 8px; }
#card:focus-within { border-color:rgba(217,119,87,.5); }
#inp { width:100%; background:none; border:none; color:var(--ink); padding:14px 12px 10px;
font:16px/1.45 system-ui,sans-serif; outline:none; }
#cardrow { display:flex; align-items:center; gap:12px; padding:0 8px 4px 12px; }
#modelname { font-size:15px; color:var(--muted); }
#cardrow .grow { flex:1; }
#send { background:var(--coral); border:none; color:#faf9f5; border-radius:999px; width:38px; height:38px;
font:500 17px/1 system-ui,sans-serif; cursor:pointer; transition:filter .2s ease; }
#send:hover { filter:brightness(1.08); }
#send:disabled { background:rgba(255,255,255,.06); color:var(--faint); cursor:default; }
#metrics { text-align:center; font-size:15px; color:var(--faint); padding:12px 0 16px; min-height:22px; }
#metrics b { color:var(--muted); font-weight:500; }
#err { color:#f87171; font-size:15px; padding:0 0 18px; text-align:center; white-space:pre-wrap; }
.spn { display:inline-block; width:1.1ch; font-family:ui-monospace,SFMono-Regular,Menlo,Consolas,monospace;
color:var(--coral-hi); margin-right:7px; }
/* CSS hologram (fallback when WebGL is unavailable/blocked): layered orb + scanlines + drift */
#holofb { position:absolute; width:min(46vw,520px); aspect-ratio:1; right:4vw; top:50%;
transform:translateY(-50%); border-radius:50%; pointer-events:none;
background:radial-gradient(circle at 38% 34%, rgba(232,152,122,.55), rgba(217,119,87,.28) 42%, rgba(196,181,253,.16) 72%, transparent 76%);
box-shadow:0 0 90px rgba(217,119,87,.25), inset 0 0 60px rgba(196,181,253,.18);
animation:holofloat 7s ease-in-out infinite; }
#holofb::before { content:""; position:absolute; inset:0; border-radius:50%;
background:repeating-linear-gradient(to bottom, rgba(255,255,255,.09) 0 2px, transparent 2px 7px);
mix-blend-mode:screen; animation:holoscan 2.6s linear infinite;
-webkit-mask:radial-gradient(circle, #000 70%, transparent 74%); mask:radial-gradient(circle, #000 70%, transparent 74%); }
#holofb::after { content:""; position:absolute; inset:-2%; border-radius:50%;
border:1px solid rgba(196,181,253,.30); filter:blur(.4px); }
@keyframes holofloat { 50% { transform:translateY(calc(-50% - 14px)); } }
@keyframes holoscan { to { background-position:0 7px; } }
@media (max-width:760px){ #holofb { right:50%; top:26%; transform:translate(50%,-50%); width:min(62vw,300px); }
@keyframes holofloat { 50% { transform:translate(50%,calc(-50% - 10px)); } } }
@media (prefers-reduced-motion: reduce){ #holofb, #holofb::before { animation:none; } }
</style>
<body>
<div class="stage on" id="arrive">
<canvas id="holo"></canvas>
<div id="holofb" hidden></div>
<div class="copy">
<h1>An AI<br>that’s yours.</h1>
<p class="sub">Bonsai streams into your browser like a film. Every piece is checked before it runs. After one visit it answers on your device, even offline.</p>
<button id="go">Stream the mind</button>
<div class="fine" id="fine">Free · open weights by Prism ML · nothing leaves your device</div>
</div>
</div>
<div class="stage" id="chat">
<div class="col" id="col">
<div id="hello">
<svg class="mark" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.6" stroke-linecap="round" aria-hidden="true"><path d="M12 3v18M3 12h18M5.6 5.6l12.8 12.8M18.4 5.6L5.6 18.4"/></svg><h2>Ready when you are.</h2>
</div>
<div id="log"></div>
<div id="card">
<input id="inp" placeholder="Ask Bonsai anything" autocomplete="off">
<div id="cardrow">
<span id="modelname">Bonsai</span>
<span class="grow"></span>
<button id="send" aria-label="Send">↑</button>
</div>
</div>
<div id="metrics">on your device</div>
<div id="err" hidden></div>
</div>
</div>
<script type="module">
// ββ the holographic centerpiece βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
// Fresnel rim + animated scan stripes + occasional slice glitch, additive-blended over the warm
// charcoal. In the spirit of ektogamat/threejs-vanilla-holographic-material (MIT) β this GLSL is
// written fresh for this page. three.js is VENDORED (no CDN) and imported AFTER first paint so
// the hero text never waits on it. On "Stream the mind" the loop stops and the GL context is
// released (dispose + lose-context) β the model engine gets the whole GPU.
const cv = document.getElementById("holo");
const reduced = matchMedia("(prefers-reduced-motion: reduce)").matches;
window.__holoOff = null;
try {
// hero paints first: two rAFs when the tab is visible, 250ms fallback when rAF is starved
// (hidden/embedded tabs never fire rAF β the hologram must still initialize for their return).
await new Promise((r) => { requestAnimationFrame(() => requestAnimationFrame(r)); setTimeout(r, 250); });
if (!document.getElementById("arrive").classList.contains("on")) throw new Error("past landing");
const THREE = await import("./vendor/three.module.min.js");
const renderer = new THREE.WebGLRenderer({ canvas: cv, antialias: true, alpha: true, powerPreference: "high-performance" });
if (!renderer.getContext() || renderer.getContext().isContextLost()) throw new Error("webgl unavailable");
renderer.setPixelRatio(Math.min(devicePixelRatio || 1, 2));
const scene = new THREE.Scene();
const cam = new THREE.PerspectiveCamera(45, 1, 0.1, 30); cam.position.z = 5;
const uni = {
uTime: { value: 0 },
uSpeed: { value: 0.35 }, // stripe scroll; boosted on hover
uGlitch: { value: reduced ? 0 : 1 },
uBase: { value: new THREE.Color("#d97757") }, // Claude coral core
uRim: { value: new THREE.Color("#c4b5fd") }, // lavender at the fresnel rim
};
const mat = new THREE.ShaderMaterial({
uniforms: uni, transparent: true, blending: THREE.AdditiveBlending, side: THREE.DoubleSide, depthWrite: false,
vertexShader: /* glsl */`
uniform float uTime; uniform float uGlitch;
varying vec3 vN; varying vec3 vW;
float rnd(float n){ return fract(sin(n)*43758.5453123); }
void main(){
vec3 p = position;
float gate = step(0.72, rnd(floor(uTime*1.8))) * uGlitch; // a burst every few seconds
float band = step(0.94, rnd(floor(p.y*9.0) + floor(uTime*7.0))); // thin horizontal slices
float g = gate * band;
p.x += (rnd(p.y*13.7 + floor(uTime*7.0)) - 0.5) * 0.22 * g;
p.z += (rnd(p.y*7.1 - floor(uTime*7.0)) - 0.5) * 0.22 * g;
vec4 w = modelMatrix * vec4(p, 1.0);
vW = w.xyz; vN = normalize(mat3(modelMatrix) * normal);
gl_Position = projectionMatrix * viewMatrix * w;
}`,
fragmentShader: /* glsl */`
uniform float uTime; uniform float uSpeed; uniform vec3 uBase; uniform vec3 uRim;
varying vec3 vN; varying vec3 vW;
void main(){
vec3 V = normalize(cameraPosition - vW);
vec3 N = normalize(vN); if (!gl_FrontFacing) N = -N;
float f = pow(1.0 - clamp(dot(V, N), 0.0, 1.0), 2.2); // fresnel rim
float s = pow(fract(vW.y * 6.0 - uTime * uSpeed), 3.0); // scan stripes
gl_FragColor = vec4(mix(uBase, uRim, f), f * 0.85 + s * 0.28 + 0.03);
}`,
});
const mesh = new THREE.Mesh(new THREE.IcosahedronGeometry(1.35, 12), mat);
const core = new THREE.Mesh(new THREE.IcosahedronGeometry(0.92, 8), mat); // inner shell: same material, real depth
mesh.add(core);
scene.add(mesh);
addEventListener("pointerdown", () => { tPulse = performance.now(); }, { passive: true }); // click: the hologram answers back
// pointer parallax: mesh tilts toward the cursor (eased); stripes speed up when the cursor is near.
let tx = 0, ty = 0, rx = 0, ry = 0, boost = 0, tBoost = 0, tPulse = -9e9;
if (!reduced) addEventListener("pointermove", (e) => {
const nx = e.clientX / innerWidth * 2 - 1, ny = e.clientY / innerHeight * 2 - 1;
tx = nx * 0.45; ty = ny * 0.35;
const c = mesh.position.clone().project(cam); // mesh center in NDC
tBoost = Math.hypot(nx - c.x, ny - c.y) < 0.55 ? 1 : 0;
}, { passive: true });
const size = () => { // right-of-center desktop Β· upper-half mobile
renderer.setSize(innerWidth, innerHeight, false);
cam.aspect = innerWidth / innerHeight; cam.updateProjectionMatrix();
const hw = Math.tan(cam.fov * Math.PI / 360) * cam.position.z; // half-height of the frustum at z=0
if (cam.aspect > 0.92) { mesh.position.set(hw * cam.aspect * 0.48, 0, 0); mesh.scale.setScalar(1); }
else { mesh.position.set(0, hw * 0.42, 0); mesh.scale.setScalar(0.78); }
};
size(); addEventListener("resize", size);
let raf = 0, dead = false;
const loop = () => {
const t = performance.now() / 1000;
uni.uTime.value = t;
boost += (tBoost - boost) * 0.06;
const pulse = Math.max(0, 1 - (performance.now() - tPulse) / 700); // click pulse decays over 0.7s
uni.uSpeed.value = 0.35 + boost * 1.1 + pulse * 2.4;
uni.uGlitch.value = reduced ? 0 : 1 + pulse * 2.0;
rx += (ty - rx) * 0.05; ry += (tx - ry) * 0.05; // eased parallax
mesh.rotation.x = rx * 0.6; mesh.rotation.y = t * 0.12 + ry; // + constant slow spin
renderer.render(scene, cam);
raf = requestAnimationFrame(loop);
};
document.addEventListener("visibilitychange", () => {
if (dead) return;
if (document.hidden) cancelAnimationFrame(raf); else raf = requestAnimationFrame(loop);
});
loop();
// verification hook: force one frame at time t and return it as a PNG (rAF is starved in
// hidden/embedded panes β this is how an agent proves the hologram actually draws pixels).
window.__holoFrame = (t) => { uni.uTime.value = t || 0; renderer.render(scene, cam); return cv.toDataURL("image/png"); };
window.__holoOff = () => { // MANDATORY before the engine loads
dead = true; cancelAnimationFrame(raf); window.__holoFrame = null;
mesh.geometry.dispose(); mat.dispose(); renderer.dispose();
try { renderer.getContext().getExtension("WEBGL_lose_context").loseContext(); } catch {}
cv.remove();
};
} catch (e) { // no WebGL (Brave shields, GPU-less) / past landing
if (document.getElementById("arrive").classList.contains("on")) {
try { cv.remove(); } catch {}
const fb = document.getElementById("holofb"); if (fb) fb.hidden = false; // the CSS hologram stands in
}
}
</script>
<script type="module">
import init, { qvac_load_gpu, qvac_gpu_free } from "../q/pkg/holospaces_web.js";
import { loadKappaObject } from "../q/holo-load2bit.mjs";
import { createQvacGPU } from "../q/qvac-gpu.js?v=68";
import { createEngine } from "../q/core/engine.js";
const $ = (id) => document.getElementById(id);
// braille pulse: one 80ms ticker animates every [data-spin] slot (loading, waking, thinking) β
// a single interval, zero layout work, stops mattering the instant the last spinner is removed.
const SPIN = ["β ","β ","β Ή","β Έ","β Ό","β ΄","β ¦","β §","β ","β "];
let _sf = 0;
setInterval(() => { const els = document.querySelectorAll("[data-spin]"); if (!els.length) return; const f = SPIN[_sf = (_sf + 1) % SPIN.length]; for (const el of els) el.textContent = f; }, 80);
const spn = () => `<span class="spn" data-spin>${SPIN[0]}</span>`;
const show = (id) => { for (const s of document.querySelectorAll(".stage")) s.classList.toggle("on", s.id === id); };
const short = (k) => String(k).replace(/^(did:holo:)?sha256:/, "").slice(0, 12) + "β¦";
// model source: ?src=<ΞΊ-object dir> for dev, HF mirror by default; ?m=27b flips to the 27B
// ΞΊ-object (engine support for its hybrid layers lands separately β the guard below is honest).
// Everything shown to the user (name, size) is READ FROM THE MANIFEST β swapping the ΞΊ URL is a
// zero-code model change. The manifest pin is the Law-L5 anchor.
const QS = new URLSearchParams(location.search);
const SRC = QS.get("src");
const DEFAULT_27B = false; // flips true the moment the hybrid engine passes parity (ΞΊ-object already published)
const M27 = QS.get("m") === "27b" || (DEFAULT_27B && QS.get("m") !== "8b");
const BASE = SRC || (M27 ? "https://huggingface.co/HOLOGRAMTECH/q-bonsai-27b/resolve/main" : "https://huggingface.co/HOLOGRAMTECH/q-bonsai-8b/resolve/main");
const PIN = M27 ? "did:holo:sha256:00beea03509a79f6567879f019c04bb15dda8721f6320f8295d9ea1dd9ba54af" : "did:holo:sha256:a0dc81f26ec5ce98b28ee9c1fab620e91c20720f777e1de6bc416317f54d27e2";
const CTX = 640;
let engine = null, gpu = null, rootK = "", warm = false, mind = [], thinkOpen = -1, thinkClose = -1;
let modelName = "Bonsai"; // set from the manifest once loaded
let entered = false, streamStarted = false;
async function stream() {
try { if (window.__holoOff) { window.__holoOff(); window.__holoOff = null; } } catch {} // hand the GPU to the engine
if (entered) { show("chat"); $("inp").focus(); } // welcome stays until the visitor chooses to enter
const t0 = performance.now();
const phase = (s) => { $("metrics").innerHTML = s; };
try {
if (!navigator.gpu) throw new Error("This browser has no WebGPU. Chrome or Edge 113+ required.");
// warm-load detect (honest offline copy): the ΞΊ-cache already holds the manifest β this visit is disk-speed.
try { const c = await caches.open("holo-kappa-v1"); warm = !!(await c.match(BASE + "/manifest.json")); } catch {}
phase(spn() + (warm ? "waking up Β· from your disk" : "streaming the mind Β· every piece verified on arrival"));
await init();
// PARALLEL ΞΊ-BLOCKS FIRST (the measured Netflix path on CDN origins): 399 content-addressed
// blocks race over 12 connections (HF cdn-lfs caps a single stream ~2 MB/s; the parallel parts
// path measured 6.8 MB/s on the same line). The ONE-file .holo stays as the fallback for
// origins that only host the wafer (and its OPFS warm store makes revisits 0-network either way).
let r, pinned = true, holo = false;
try {
r = await loadKappaObject(BASE, { expectKappa: PIN, blake3: false });
} catch (e1) {
try {
const hs = await import("../q/core/holo-stream-load.mjs");
r = await hs.openHoloKappa(BASE + "/q-bonsai-8b.v1.holo", {});
holo = true; warm = !!r.warm;
} catch (e) { if (!SRC) throw e; pinned = false; r = await loadKappaObject(BASE, { allowUnpinned: true, blake3: false }); } // dev fallback only under ?src
}
rootK = (r.info && r.info.root) || PIN;
modelName = String((r.info && r.info.model) || "Bonsai").replace(/-/g, " ");
$("modelname").textContent = modelName;
// HONESTY GATE: the hybrid (27B) engine ships separately β never pretend to run what we can't.
if (r.manifest.hybrid) throw new Error(modelName + " uses a hybrid engine this build does not include yet. It is arriving; the 8B runs today.");
// progress = ONE quiet line under the input (per-tensor counters; no grid, no takeover)
const total = (r.manifest.tensors || []).length;
let done = 0, bytes = 0;
const tick = () => {
const dt = (performance.now() - t0) / 1000;
if (warm) phase(`${spn()}waking up Β· ${Math.round(done / Math.max(total, 1) * 100)}%`);
else phase(`${spn()}streaming the mind Β· <b>${(bytes / 1e6).toFixed(0)} MB</b> Β· ${(bytes / 1e6 / Math.max(dt, .1)).toFixed(1)} MB/s Β· every piece verified on arrival`);
};
const iv = setInterval(tick, 400);
const fetchT = async (name) => { // wrap fetchTensor: the progress driver
const b = await r.fetchTensor(name);
bytes += b.byteLength; done++;
return b;
};
// tokenizer header (arch + vocab) β embedded in the .holo (0 extra fetches), else same ΞΊ-object dir.
const hdr = r.tokenizerBytes || new Uint8Array(await (await fetch(BASE + "/tokenizer.gguf")).arrayBuffer());
const lr = JSON.parse(qvac_load_gpu(hdr));
if (lr.error) throw new Error("tokenizer: " + lr.error);
try { qvac_gpu_free(); } catch {}
r.manifest.kv4 = false; // exact f32 KV (the proven first-light config)
gpu = await createQvacGPU(r.manifest, fetchT, CTX, lr.eos ?? 2, false);
clearInterval(iv);
phase(spn() + "waking the mind");
const m = { fam: "Bonsai", name: modelName, size: "1.16 GB", fmt: "q1 1-bit ΞΊ", cap: 200, ctx: CTX, qwen: true, chat: true, rep: 1.05, gpu: true, gpuOnly: true };
engine = await createEngine(m, { gpu, info: lr, imageKappa: r.info.root });
// Qwen3 thinking markers are atomic tokens and clean() strips them from text β split by token id instead.
const o = engine.tokenize("<think>"), c2 = engine.tokenize("</think>");
thinkOpen = o.length === 1 ? o[0] : -1; thinkClose = c2.length === 1 ? c2[0] : -1;
enterChat();
} catch (e) {
$("metrics").textContent = ""; $("err").hidden = false;
$("err").textContent = String(e && e.message || e);
console.error(e);
}
}
// the ONLY chat metrics, one quiet line: model Β· time to first word Β· tok/s (operator spec)
let lastTTFT = null, lastTokps = null;
function metrics(state) {
const bits = [`<b>${modelName}</b>`];
if (lastTTFT != null) bits.push(`${lastTTFT.toFixed(1)}s to first word`);
if (lastTokps != null) bits.push(`<b>${lastTokps.toFixed(0)}</b> tokens a second`);
if (!lastTTFT && !lastTokps) bits.push(state || (warm ? "from your disk Β· works offline" : "on your device"));
$("metrics").innerHTML = bits.join(" · ");
}
let pendingQ = null;
function enterChat() {
ready = true; $("send").disabled = false; metrics();
if (pendingQ) { $("inp").value = pendingQ; pendingQ = null; send(); }
else if (entered) $("inp").focus();
}
const log = $("log");
function msg(who, cls) {
const d = document.createElement("div"); d.className = "msg " + cls;
d.innerHTML = `<div class="who">${who}</div>`;
const think = document.createElement("details"); think.className = "think"; think.hidden = true;
think.innerHTML = `<summary><span class="sum">thinkingβ¦</span></summary><div class="t"></div>`;
const body = document.createElement("div"); body.className = "body";
d.appendChild(think); d.appendChild(body); log.appendChild(d);
log.scrollTop = log.scrollHeight;
return { body, think, t: think.querySelector(".t") };
}
function note(s) { const d = document.createElement("div"); d.className = "note"; d.textContent = s; log.appendChild(d); }
// split streamed outIds into thinking + answer segments by the <think> token ids (robust: no
// tags at position 0 β everything is answer; unclosed β everything so far is thinking).
function splitThink(outIds) {
if (thinkOpen < 0 || outIds[0] !== thinkOpen) return { think: [], ans: outIds };
const c = outIds.indexOf(thinkClose);
if (c < 0) return { think: outIds.slice(1), ans: [] };
return { think: outIds.slice(1, c), ans: outIds.slice(c + 1) };
}
let busy = false, ready = false;
async function send() {
const q = $("inp").value.trim();
if (!q || busy) return;
if (!ready || !engine) { // the mind is still arriving: hold ONE question, it sends itself
pendingQ = q; $("inp").value = "";
$("col").classList.add("started");
msg("You", "user").body.textContent = q;
note("your question will send itself the moment the mind arrives");
return;
}
busy = true; $("inp").value = ""; $("send").disabled = true;
$("col").classList.add("started"); // the greeting yields to the conversation (Claude-room transition)
msg("You", "user").body.textContent = q;
const turn = engine.tokenize(engine.frameTurn(q, mind.length > 0));
if (mind.length + turn.length + 256 > CTX) { mind = []; note("fresh context"); } // keep β₯256 tokens of room (thinking model)
const ids = mind.concat(mind.length ? turn : engine.tokenize(engine.frameTurn(q, false)));
const ui = msg(modelName, "bot"); ui.body.innerHTML = spn();
ui.think.querySelector("summary").innerHTML = spn() + `<span class="sum">thinking</span>`;
const tSend = performance.now(); let ttftSet = false;
lastTTFT = null; lastTokps = null;
$("metrics").innerHTML = spn() + `<b>${modelName}</b> is thinking`;
try {
const res = await engine.generate(ids, {
maxNew: CTX - ids.length - 8, // the whole remaining KV window (eos stops early)
onToken: (t) => {
if (!ttftSet) { ttftSet = true; lastTTFT = (performance.now() - tSend) / 1000; } // TTFT = send β first visible token
if (t.stats && t.stats.tokps) lastTokps = t.stats.tokps;
metrics();
const s = splitThink(t.outIds);
if (s.think.length) { ui.think.hidden = false; ui.t.textContent = engine.detokenize(s.think); }
if (s.ans.length) ui.think.querySelector("summary").innerHTML = `<span class="sum">thinkingβ¦</span>`; // answer flowing: the pulse retires
ui.body.textContent = s.ans.length ? engine.detokenize(s.ans) : (s.think.length ? "" : t.text);
log.scrollTop = log.scrollHeight;
},
});
const s = splitThink(res.outIds || []);
ui.think.querySelector("summary").innerHTML = `<span class="sum">thinkingβ¦</span>`;
if (s.think.length) { ui.think.hidden = false; ui.t.textContent = engine.detokenize(s.think); }
if (s.ans.length) {
ui.body.textContent = engine.detokenize(s.ans);
mind = ids.concat(s.ans); // history carries the ANSWER only (Qwen3 convention: prior-turn thinking dropped)
} else if (s.think.length) {
ui.body.textContent = "I ran out of room while thinking. Ask again, a bit shorter."; // unclosed <think> at the window edge; turn not kept
} else {
ui.body.textContent = res.text;
mind = ids.concat(res.outIds || []);
}
if (res.stats && res.stats.tokps) lastTokps = res.stats.tokps;
metrics();
} catch (e) { ui.body.textContent = "Something broke: " + (e && e.message || e); }
busy = false; $("send").disabled = false; $("inp").focus();
log.scrollTop = log.scrollHeight;
}
$("go").addEventListener("click", () => {
entered = true; show("chat"); $("inp").focus();
if (!streamStarted) { streamStarted = true; stream(); }
});
$("send").disabled = true; // until the mind is resident (early questions queue)
(async () => {
try {
if (navigator.connection && navigator.connection.saveData) return; // respect data saver
if (SRC) return; // dev override: no background pulls
const B27 = "https://huggingface.co/HOLOGRAMTECH/q-bonsai-27b/resolve/main";
const cache = await caches.open("holo-kappa-v1");
const man = await (await fetch(B27 + "/manifest.json")).json();
const urls = Object.values(man.tensors || {}).map((r) => B27 + "/b/" + String(r.kappa).replace(":", "_") + ".gz");
let i = 0;
const worker = async () => {
while (i < urls.length) {
const u = urls[i++];
if (await cache.match(u)) continue;
while (streamStarted && !ready) await new Promise((r) => setTimeout(r, 1500)); // the live stream owns the wire
try { const b = await (await fetch(u, { cache: "no-store" })).arrayBuffer(); await cache.put(u, new Response(b, { headers: { "Content-Type": "application/octet-stream" } })); } catch {}
}
};
Promise.all(Array.from({ length: 3 }, worker)).catch(() => {});
} catch {}
})();
(async () => { // returning visitor: the mind wakes BEHIND the welcome screen
try { const c = await caches.open("holo-kappa-v1"); if (await c.match(BASE + "/manifest.json")) { streamStarted = true; stream(); } } catch {}
})();
$("send").addEventListener("click", send);
$("inp").addEventListener("keydown", (e) => { if (e.key === "Enter") send(); });
if (!navigator.gpu) { $("go").disabled = true; $("fine").textContent = "This browser has no WebGPU. Chrome or Edge 113 or newer required."; }
</script>
</body>sha256/0c8428aa060ee191f5552ea4663929918e752eb243bb70c416c61a29101523b9Added
sha256/2cc65275ca0cca65fc77a47bfd7cf1ce6e79d9b1fedb22f9eada6a6b31dfcab3Added+1
sha256/3f1449137aa9b623734ecbd90e436b7467908eece30d18ab1fa7c548642c8938Added
sha256/85be07b7411283d43c035f9c98980ff63f76bd9e12df153d75e7712efaae2f3aAdded+460