NakliTechie commited on
Commit
c91c597
Β·
1 Parent(s): a1724d4

Sync from GitHub 2026-10-24T01:38:01Z

Browse files
Files changed (1) hide show
  1. index.html +58 -52
index.html CHANGED
@@ -8014,11 +8014,13 @@ const engineFetch = async (url, init = {}) => {
8014
  // ── End shared engine-worker prelude ──────────────────────────────────────
8015
  </script>
8016
  <script type="text/worker" id="gemma4WebgpuWorkerSrc">
8017
- // The factory replaces __GEMMA4_ENGINE_URL__ with the engine's rolled-in module URL (moduleUrl()).
8018
- const ENGINE_URL = '__GEMMA4_ENGINE_URL__';
8019
- const PLE_URL = '__GEMMA4_PLE_URL__'; // ple-opfs.js: the per-layer embedding table served from OPFS
 
8020
 
8021
- let Gemma4Mobile = null;
 
8022
  let model = null;
8023
  let abortController = null;
8024
  let stopFlag = false;
@@ -8033,31 +8035,24 @@ self.onmessage = async (e) => {
8033
  const d = e.data || {};
8034
  try {
8035
  if (d.type === 'load') {
8036
- if (!Gemma4Mobile) ({ Gemma4Mobile } = await import(ENGINE_URL));
8037
  WEIGHTS_LABEL = /E4B/.test(d.modelId || '') ? 'Gemma 4 E4B (QAT)' : 'Gemma 4 E2B (QAT)';
8038
  hfToken = (typeof d.hfToken === 'string' && d.hfToken.trim()) || null;
8039
  post({ type: 'progress', data: { status: 'initiate', file: WEIGHTS_LABEL } });
8040
- // Settings β†’ Models "per-layer embeddings from disk": the engine writes the
8041
- // 1.2 GB PLE table to OPFS once and keeps only a row cache on the GPU. When
8042
- // OPFS is unusable, attach() returns null and the table stays resident.
8043
- let ple;
8044
- if (d.ple) {
8045
- const { createGemmaPle } = await import(PLE_URL);
8046
- ple = createGemmaPle({
8047
- source: { repo: d.modelId || Gemma4Mobile.DEFAULT_MODEL_ID },
8048
- onStatus: (s) => {
8049
- if (s.phase === 'write') post({ type: 'progress', data: { status: 'loading', file: 'per-layer embeddings to disk (once)' } });
8050
- else if (s.phase === 'fallback') console.warn('Gemma 4 PLE from disk unavailable, keeping it on the GPU:', s.error);
8051
- },
8052
- });
8053
- }
8054
- // load(modelId, opts): a repo id resolves the QAT-mobile weight root;
8055
- // null falls back to the engine's DEFAULT_MODEL_ID (the same repo).
8056
- model = await Gemma4Mobile.load(d.modelId || null, {
8057
- ple,
8058
  fetch: engineFetch,
8059
  onProgress: (ev) => {
8060
  if (!ev) return;
 
 
 
 
 
8061
  if (ev.status === 'weights' && ev.kind === 'tensors') {
8062
  // Post-download phases: tensor upload to the GPU (counted in tensors,
8063
  // not bytes β€” must not drive the MB bar), then kernel warmup.
@@ -8081,11 +8076,14 @@ self.onmessage = async (e) => {
8081
  post({ type: 'progress', data: { status: 'loading', file: 'tokenizer' } });
8082
  } else if (ev.status === 'init') {
8083
  post({ type: 'progress', data: { status: 'initiate', file: 'WebGPU device' } });
 
 
8084
  }
8085
  },
8086
  });
 
 
8087
  lastHistoryLen = 0;
8088
- try { if (typeof model.warmup === 'function') await model.warmup(); } catch (_) {}
8089
  // ple: where the per-layer embedding table lives ('opfs' or 'resident'), for diagnostics.
8090
  post({ type: 'ready', backend: 'webgpu', ple: model.pleMode || 'resident' });
8091
  } else if (d.type === 'generate') {
@@ -8150,8 +8148,8 @@ self.onmessage = async (e) => {
8150
  stopFlag = true;
8151
  if (abortController) { try { abortController.abort(); } catch (_) {} }
8152
  try { if (model && typeof model.reset === 'function') model.reset(); } catch (_) {}
8153
- try { if (model && typeof model.dispose === 'function') model.dispose(); } catch (_) {}
8154
- model = null;
8155
  lastHistoryLen = 0;
8156
  }
8157
  } catch (err) {
@@ -8160,9 +8158,11 @@ self.onmessage = async (e) => {
8160
  };
8161
  </script>
8162
  <script type="text/worker" id="ternaryBonsai2WebgpuWorkerSrc">
8163
- // The factory replaces __TERNARY_BONSAI2_ENGINE_URL__ / __TERNARY_BONSAI2_DFLASH_URL__ with the
8164
- // engine's and the DFlash module's rolled-in module URLs (moduleUrl()).
8165
- const ENGINE_URL = '__TERNARY_BONSAI2_ENGINE_URL__';
 
 
8166
  const DFLASH_URL = '__TERNARY_BONSAI2_DFLASH_URL__';
8167
  const MTP_URL = '__TERNARY_BONSAI2_MTP_URL__';
8168
  // MTP speculative decoding (Settings β†’ Models, default OFF; posted as `mtp` + `mtpDepth` on the
@@ -8182,7 +8182,8 @@ const DRAFTER_URL = 'https://huggingface.co/naklitechie/Qwen3.8-27B-DFlash2-tern
8182
  const DRAFTER_CACHE = 'dflash-drafter-v1';
8183
  const DFLASH_BLOCK = 5; // verify block length: 1.17Γ— on code at 5, 1.09Γ— at 8 (dflash-mlx-bonsai2 lab/webgpu/runner/RESULTS.md)
8184
 
8185
- let TernaryBonsai2 = null;
 
8186
  let model = null;
8187
  let dflash = null; // the attached DFlashRunner, or null (plain decode)
8188
  let lastDflashGen = 0, lastDflashStats = { cycles: 0, tokens: 0, accepted: 0, drafted: 0, plainTokens: 0 };
@@ -8201,16 +8202,20 @@ self.onmessage = async (e) => {
8201
  const d = e.data || {};
8202
  try {
8203
  if (d.type === 'load') {
8204
- if (!TernaryBonsai2) ({ TernaryBonsai2 } = await import(ENGINE_URL));
8205
  hfToken = (typeof d.hfToken === 'string' && d.hfToken.trim()) || null;
8206
  post({ type: 'progress', data: { status: 'initiate', file: WEIGHTS_LABEL } });
8207
  // load(modelId, opts): null falls back to the engine's DEFAULT_MODEL_ID
8208
  // (upstream's own ungated prism-ml/Ternary-Bonsai-2-27B-gguf, PTQ1_0 file).
8209
  // maxLength sizes the KV/recurrent cache; the registry's contextSize wins
8210
  // over the engine's 16K default so the two never drift apart.
8211
- model = await TernaryBonsai2.load(d.modelId || null, {
 
 
 
 
8212
  fetch: engineFetch,
8213
- maxLength: d.contextSize > 0 ? d.contextSize : undefined,
8214
  onProgress: (ev) => {
8215
  if (!ev) return;
8216
  if (ev.status === 'weights' && ev.kind === 'tensors') {
@@ -8237,11 +8242,14 @@ self.onmessage = async (e) => {
8237
  post({ type: 'progress', data: { status: 'loading', file: 'tokenizer' } });
8238
  } else if (ev.status === 'init') {
8239
  post({ type: 'progress', data: { status: 'initiate', file: 'WebGPU device' } });
 
 
8240
  }
8241
  },
8242
  });
 
 
8243
  lastHistoryLen = 0;
8244
- try { if (typeof model.warmup === 'function') await model.warmup(); } catch (_) {}
8245
  post({ type: 'ready', backend: 'webgpu' });
8246
  if (d.mtp === true) attachMTP(d.mtpDepth).catch((err) => { post({ type: 'dflash', kind: 'mtp', status: 'error', message: (err && err.message) || String(err) }); });
8247
  else if (d.dflash !== false) attachDFlash().catch((err) => { post({ type: 'dflash', status: 'error', message: (err && err.message) || String(err) }); });
@@ -8418,8 +8426,8 @@ self.onmessage = async (e) => {
8418
  try { if (model && typeof model.reset === 'function') model.reset(); } catch (_) {}
8419
  try { if (dflash) { if (model) model.model.dflashRunner = null; dflash.dispose(); } } catch (_) {}
8420
  dflash = null;
8421
- try { if (model && typeof model.dispose === 'function') model.dispose(); } catch (_) {}
8422
- model = null;
8423
  lastHistoryLen = 0;
8424
  }
8425
  } catch (err) {
@@ -17804,17 +17812,13 @@ self.addEventListener('message', async (e) => {
17804
  }
17805
 
17806
  // ── Gemma 4 WebGPU-kernels worker factory (custom-WGSL Gemma4Mobile engine) ──
17807
- // Twin of createLfm2WebgpuWorker(): prepends the shared prelude, reads
17808
- // #gemma4WebgpuWorkerSrc, injects the rolled-in gemma-4-e2b.js engine's
17809
- // module URL, and builds a blob
17810
- // module worker that speaks the shared chat protocol.
17811
  function createGemma4WebgpuWorker() {
17812
  const src = document.getElementById('gemma4WebgpuWorkerSrc');
17813
  let code = src ? src.textContent : '';
17814
  if (!code) throw new Error('Gemma 4 WebGPU worker source missing');
17815
- const engineUrl = moduleUrl('gemma-4-e2b.js');
17816
- const pleUrl = moduleUrl('ple-opfs.js');
17817
- code = engineWorkerPrelude() + code.replaceAll('__GEMMA4_ENGINE_URL__', engineUrl).replaceAll('__GEMMA4_PLE_URL__', pleUrl);
17818
  const blob = new Blob([code], { type: 'application/javascript' });
17819
  const url = URL.createObjectURL(blob);
17820
  const w = new Worker(url, { type: 'module' });
@@ -17826,16 +17830,15 @@ self.addEventListener('message', async (e) => {
17826
 
17827
  // ── Ternary Bonsai 2 27B WebGPU-kernels worker factory (custom-WGSL TernaryBonsai2 engine) ──
17828
  // Twin of createLfm2WebgpuWorker(): prepends the shared prelude, reads #ternaryBonsai2WebgpuWorkerSrc, injects the
17829
- // rolled-in ternary_bonsai_2_27b.js engine's module URL, and builds a blob
17830
  // module worker that speaks the shared chat protocol. Ternary PTQ1_0 GGUF (~5.9 GB).
17831
  function createTernaryBonsai2WebgpuWorker() {
17832
  const src = document.getElementById('ternaryBonsai2WebgpuWorkerSrc');
17833
  let code = src ? src.textContent : '';
17834
  if (!code) throw new Error('Ternary Bonsai 2 27B WebGPU worker source missing');
17835
- const engineUrl = moduleUrl('ternary_bonsai_2_27b.js');
17836
  const dflashUrl = moduleUrl('ternary_bonsai_2_dflash.js');
17837
  const mtpUrl = moduleUrl('ternary_bonsai_2_mtp.js');
17838
- code = engineWorkerPrelude() + code.replaceAll('__TERNARY_BONSAI2_ENGINE_URL__', engineUrl).replaceAll('__TERNARY_BONSAI2_DFLASH_URL__', dflashUrl).replaceAll('__TERNARY_BONSAI2_MTP_URL__', mtpUrl);
17839
  const blob = new Blob([code], { type: 'application/javascript' });
17840
  const url = URL.createObjectURL(blob);
17841
  const w = new Worker(url, { type: 'module' });
@@ -24026,7 +24029,7 @@ self.addEventListener('message', async (e) => {
24026
  * AnyformerModel gives an anyformer session the engine interface LocalMind's SSD worker drives (moeSsdWorkerSrc):
24027
  * static load(null, { maxCtx, localFile, onProgress, signal }), generate(messages, { maxNewTokens, signal,
24028
  * enableThinking }) streaming { text, token }, prime(), ensureVision(), reset(), dispose(), and the think markers. One
24029
- * subclass per model names its repo. anyformer loads from npm through jsDelivr, at an exact version.
24030
  *
24031
  * Two shapes of session (anyformer v0.3.0):
24032
  * - a diskformer hand engine: chunks carry the engine's token ids and session.think its markers, so they pass
@@ -24037,7 +24040,7 @@ self.addEventListener('message', async (e) => {
24037
  */
24038
  const THINK_CLOSE = -2;
24039
 
24040
- export const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.3.2/index.js';
24041
 
24042
  // anyformer's progress events β†’ the engine events the SSD worker posts. The llama.cpp path reports 'download' (bytes
24043
  // into OPFS) and 'load' / 'plan'; a hand engine (diskformer back end) reports its own engine events, 'weights' with
@@ -32364,9 +32367,12 @@ export class HyV3MoeSsd extends Lfm2MoeSsd {
32364
  const PROTOCOL = 'localmind.inference.v1';
32365
  const DEFAULT_MODEL_ID = 'LiquidAI/LFM2.5-230M-GGUF';
32366
  const GGUF_FILE = 'LFM2.5-230M-Q4_0.gguf';
32367
- const ENGINE_URL = new URL('./lfm2_5.js', import.meta.url).href;
 
 
 
32368
 
32369
- let Lfm2Mobile = null;
32370
  let model = null;
32371
  let abortController = null;
32372
  let stopFlag = false;
@@ -32509,10 +32515,10 @@ const loadModel = async (request) => {
32509
  post({ type: 'ready', backend: 'webgpu', model: request.modelId || DEFAULT_MODEL_ID }, id);
32510
  return;
32511
  }
32512
- if (!Lfm2Mobile) ({ Lfm2Mobile } = await import(ENGINE_URL));
32513
  hfToken = (typeof request.hfToken === 'string' && request.hfToken.trim()) || null;
32514
  post({ type: 'progress', data: { status: 'initiate', file: GGUF_FILE } }, id);
32515
- model = await Lfm2Mobile.load(request.modelId || DEFAULT_MODEL_ID, {
32516
  // Range reads stream + resume and carry the optional HF token (prelude).
32517
  fetch: engineFetch,
32518
  onProgress: (event) => {
 
8014
  // ── End shared engine-worker prelude ──────────────────────────────────────
8015
  </script>
8016
  <script type="text/worker" id="gemma4WebgpuWorkerSrc">
8017
+ // The model loads through anyformer (convergence plan, 2026-10-22): anyformer resolves the repo to diskformer's copy
8018
+ // of the engine (Gemma4Mobile) and, with ple, builds the OPFS per-layer-embedding table itself. The worker then drives
8019
+ // session.engine exactly as it drove its own engine. Pinned to the same anyformer as anyformer_models.js.
8020
+ const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.4.1/index.js';
8021
 
8022
+ let anyformerLoad = null;
8023
+ let session = null;
8024
  let model = null;
8025
  let abortController = null;
8026
  let stopFlag = false;
 
8035
  const d = e.data || {};
8036
  try {
8037
  if (d.type === 'load') {
8038
+ if (!anyformerLoad) ({ load: anyformerLoad } = await import(ANYFORMER_URL));
8039
  WEIGHTS_LABEL = /E4B/.test(d.modelId || '') ? 'Gemma 4 E4B (QAT)' : 'Gemma 4 E2B (QAT)';
8040
  hfToken = (typeof d.hfToken === 'string' && d.hfToken.trim()) || null;
8041
  post({ type: 'progress', data: { status: 'initiate', file: WEIGHTS_LABEL } });
8042
+ // Settings β†’ Models "per-layer embeddings from disk" (ple): the engine writes the 1.2 GB PLE table to OPFS once
8043
+ // and keeps only a row cache on the GPU; when OPFS is unusable the table stays resident. anyformer reports the
8044
+ // table's phases as status 'ple'. The budget only admits the model (the whole of E4B, 3.5 GB, stays on the GPU).
8045
+ session = await anyformerLoad(d.modelId, {
8046
+ budget: 8e9,
8047
+ ple: !!d.ple,
 
 
 
 
 
 
 
 
 
 
 
 
8048
  fetch: engineFetch,
8049
  onProgress: (ev) => {
8050
  if (!ev) return;
8051
+ if (ev.status === 'ple') {
8052
+ if (ev.phase === 'write') post({ type: 'progress', data: { status: 'loading', file: 'per-layer embeddings to disk (once)' } });
8053
+ else if (ev.phase === 'fallback') console.warn('Gemma 4 PLE from disk unavailable, keeping it on the GPU:', ev.error);
8054
+ return;
8055
+ }
8056
  if (ev.status === 'weights' && ev.kind === 'tensors') {
8057
  // Post-download phases: tensor upload to the GPU (counted in tensors,
8058
  // not bytes β€” must not drive the MB bar), then kernel warmup.
 
8076
  post({ type: 'progress', data: { status: 'loading', file: 'tokenizer' } });
8077
  } else if (ev.status === 'init') {
8078
  post({ type: 'progress', data: { status: 'initiate', file: 'WebGPU device' } });
8079
+ } else if (ev.status === 'warmup') {
8080
+ post({ type: 'warmup' });
8081
  }
8082
  },
8083
  });
8084
+ // anyformer compiled the kernels during load (its 'warmup' phase), so the engine is ready to generate.
8085
+ model = session.engine;
8086
  lastHistoryLen = 0;
 
8087
  // ple: where the per-layer embedding table lives ('opfs' or 'resident'), for diagnostics.
8088
  post({ type: 'ready', backend: 'webgpu', ple: model.pleMode || 'resident' });
8089
  } else if (d.type === 'generate') {
 
8148
  stopFlag = true;
8149
  if (abortController) { try { abortController.abort(); } catch (_) {} }
8150
  try { if (model && typeof model.reset === 'function') model.reset(); } catch (_) {}
8151
+ try { if (session) await session.dispose(); } catch (_) {}
8152
+ session = null; model = null;
8153
  lastHistoryLen = 0;
8154
  }
8155
  } catch (err) {
 
8158
  };
8159
  </script>
8160
  <script type="text/worker" id="ternaryBonsai2WebgpuWorkerSrc">
8161
+ // The factory replaces __TERNARY_BONSAI2_DFLASH_URL__ / __TERNARY_BONSAI2_MTP_URL__ with the DFlash and MTP modules'
8162
+ // rolled-in module URLs (moduleUrl()).
8163
+ // The model loads through anyformer (convergence plan, 2026-10-22): anyformer resolves the repo to diskformer's copy of
8164
+ // the engine (TernaryBonsai2); the worker drives session.engine as before and attaches DFlash / MTP itself.
8165
+ const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.4.1/index.js';
8166
  const DFLASH_URL = '__TERNARY_BONSAI2_DFLASH_URL__';
8167
  const MTP_URL = '__TERNARY_BONSAI2_MTP_URL__';
8168
  // MTP speculative decoding (Settings β†’ Models, default OFF; posted as `mtp` + `mtpDepth` on the
 
8182
  const DRAFTER_CACHE = 'dflash-drafter-v1';
8183
  const DFLASH_BLOCK = 5; // verify block length: 1.17Γ— on code at 5, 1.09Γ— at 8 (dflash-mlx-bonsai2 lab/webgpu/runner/RESULTS.md)
8184
 
8185
+ let anyformerLoad = null;
8186
+ let session = null;
8187
  let model = null;
8188
  let dflash = null; // the attached DFlashRunner, or null (plain decode)
8189
  let lastDflashGen = 0, lastDflashStats = { cycles: 0, tokens: 0, accepted: 0, drafted: 0, plainTokens: 0 };
 
8202
  const d = e.data || {};
8203
  try {
8204
  if (d.type === 'load') {
8205
+ if (!anyformerLoad) ({ load: anyformerLoad } = await import(ANYFORMER_URL));
8206
  hfToken = (typeof d.hfToken === 'string' && d.hfToken.trim()) || null;
8207
  post({ type: 'progress', data: { status: 'initiate', file: WEIGHTS_LABEL } });
8208
  // load(modelId, opts): null falls back to the engine's DEFAULT_MODEL_ID
8209
  // (upstream's own ungated prism-ml/Ternary-Bonsai-2-27B-gguf, PTQ1_0 file).
8210
  // maxLength sizes the KV/recurrent cache; the registry's contextSize wins
8211
  // over the engine's 16K default so the two never drift apart.
8212
+ // The registry's id is a repo (27B) or a file URL (2B, 4B: …/<repo>/resolve/main/<file>); anyformer takes the repo
8213
+ // and picks the PTQ1_0 file. The budget only admits the model (all 5.9 GB of the 27B stays on the GPU).
8214
+ const repo = /^https?:\/\/huggingface\.co\/([^/]+\/[^/]+)\/resolve\//.exec(d.modelId || '')?.[1] || d.modelId || 'prism-ml/Ternary-Bonsai-2-27B-gguf';
8215
+ session = await anyformerLoad(repo, {
8216
+ budget: 8e9,
8217
  fetch: engineFetch,
8218
+ maxCtx: d.contextSize > 0 ? d.contextSize : undefined,
8219
  onProgress: (ev) => {
8220
  if (!ev) return;
8221
  if (ev.status === 'weights' && ev.kind === 'tensors') {
 
8242
  post({ type: 'progress', data: { status: 'loading', file: 'tokenizer' } });
8243
  } else if (ev.status === 'init') {
8244
  post({ type: 'progress', data: { status: 'initiate', file: 'WebGPU device' } });
8245
+ } else if (ev.status === 'warmup') {
8246
+ post({ type: 'warmup' });
8247
  }
8248
  },
8249
  });
8250
+ // anyformer compiled the kernels during load (its 'warmup' phase).
8251
+ model = session.engine;
8252
  lastHistoryLen = 0;
 
8253
  post({ type: 'ready', backend: 'webgpu' });
8254
  if (d.mtp === true) attachMTP(d.mtpDepth).catch((err) => { post({ type: 'dflash', kind: 'mtp', status: 'error', message: (err && err.message) || String(err) }); });
8255
  else if (d.dflash !== false) attachDFlash().catch((err) => { post({ type: 'dflash', status: 'error', message: (err && err.message) || String(err) }); });
 
8426
  try { if (model && typeof model.reset === 'function') model.reset(); } catch (_) {}
8427
  try { if (dflash) { if (model) model.model.dflashRunner = null; dflash.dispose(); } } catch (_) {}
8428
  dflash = null;
8429
+ try { if (session) await session.dispose(); } catch (_) {}
8430
+ session = null; model = null;
8431
  lastHistoryLen = 0;
8432
  }
8433
  } catch (err) {
 
17812
  }
17813
 
17814
  // ── Gemma 4 WebGPU-kernels worker factory (custom-WGSL Gemma4Mobile engine) ──
17815
+ // Twin of createLfm2WebgpuWorker(): prepends the shared prelude to #gemma4WebgpuWorkerSrc and builds a blob module
17816
+ // worker that speaks the shared chat protocol. The engine comes through anyformer (diskformer's copy).
 
 
17817
  function createGemma4WebgpuWorker() {
17818
  const src = document.getElementById('gemma4WebgpuWorkerSrc');
17819
  let code = src ? src.textContent : '';
17820
  if (!code) throw new Error('Gemma 4 WebGPU worker source missing');
17821
+ code = engineWorkerPrelude() + code;
 
 
17822
  const blob = new Blob([code], { type: 'application/javascript' });
17823
  const url = URL.createObjectURL(blob);
17824
  const w = new Worker(url, { type: 'module' });
 
17830
 
17831
  // ── Ternary Bonsai 2 27B WebGPU-kernels worker factory (custom-WGSL TernaryBonsai2 engine) ──
17832
  // Twin of createLfm2WebgpuWorker(): prepends the shared prelude, reads #ternaryBonsai2WebgpuWorkerSrc, injects the
17833
+ // rolled-in DFlash and MTP modules' URLs (the engine itself comes through anyformer), and builds a blob
17834
  // module worker that speaks the shared chat protocol. Ternary PTQ1_0 GGUF (~5.9 GB).
17835
  function createTernaryBonsai2WebgpuWorker() {
17836
  const src = document.getElementById('ternaryBonsai2WebgpuWorkerSrc');
17837
  let code = src ? src.textContent : '';
17838
  if (!code) throw new Error('Ternary Bonsai 2 27B WebGPU worker source missing');
 
17839
  const dflashUrl = moduleUrl('ternary_bonsai_2_dflash.js');
17840
  const mtpUrl = moduleUrl('ternary_bonsai_2_mtp.js');
17841
+ code = engineWorkerPrelude() + code.replaceAll('__TERNARY_BONSAI2_DFLASH_URL__', dflashUrl).replaceAll('__TERNARY_BONSAI2_MTP_URL__', mtpUrl);
17842
  const blob = new Blob([code], { type: 'application/javascript' });
17843
  const url = URL.createObjectURL(blob);
17844
  const w = new Worker(url, { type: 'module' });
 
24029
  * AnyformerModel gives an anyformer session the engine interface LocalMind's SSD worker drives (moeSsdWorkerSrc):
24030
  * static load(null, { maxCtx, localFile, onProgress, signal }), generate(messages, { maxNewTokens, signal,
24031
  * enableThinking }) streaming { text, token }, prime(), ensureVision(), reset(), dispose(), and the think markers. One
24032
+ * subclass per model names its repo. anyformer loads from jsDelivr at an exact version (a GitHub tag until it is on npm).
24033
  *
24034
  * Two shapes of session (anyformer v0.3.0):
24035
  * - a diskformer hand engine: chunks carry the engine's token ids and session.think its markers, so they pass
 
24040
  */
24041
  const THINK_CLOSE = -2;
24042
 
24043
+ export const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.4.1/index.js';
24044
 
24045
  // anyformer's progress events β†’ the engine events the SSD worker posts. The llama.cpp path reports 'download' (bytes
24046
  // into OPFS) and 'load' / 'plan'; a hand engine (diskformer back end) reports its own engine events, 'weights' with
 
32367
  const PROTOCOL = 'localmind.inference.v1';
32368
  const DEFAULT_MODEL_ID = 'LiquidAI/LFM2.5-230M-GGUF';
32369
  const GGUF_FILE = 'LFM2.5-230M-Q4_0.gguf';
32370
+ // The model loads through anyformer (convergence plan, 2026-10-22): anyformer resolves the repo to diskformer's copy of
32371
+ // the LFM2.5 engine (Lfm2Mobile) and returns a session with the same generate / reset / dispose. Pinned to an exact
32372
+ // version; LocalMind's anyformer_models.js pins the same one.
32373
+ const ANYFORMER_URL = 'https://cdn.jsdelivr.net/npm/anyformer@0.4.1/index.js';
32374
 
32375
+ let anyformerLoad = null;
32376
  let model = null;
32377
  let abortController = null;
32378
  let stopFlag = false;
 
32515
  post({ type: 'ready', backend: 'webgpu', model: request.modelId || DEFAULT_MODEL_ID }, id);
32516
  return;
32517
  }
32518
+ if (!anyformerLoad) ({ load: anyformerLoad } = await import(ANYFORMER_URL));
32519
  hfToken = (typeof request.hfToken === 'string' && request.hfToken.trim()) || null;
32520
  post({ type: 'progress', data: { status: 'initiate', file: GGUF_FILE } }, id);
32521
+ model = await anyformerLoad(request.modelId || DEFAULT_MODEL_ID, {
32522
  // Range reads stream + resume and carry the optional HF token (prelude).
32523
  fetch: engineFetch,
32524
  onProgress: (event) => {