brsh 3.3.1 → 3.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ # [3.4.0](https://github.com/eliotstocker/Brsh-JS/compare/v3.3.1...v3.4.0) (2026-11-09)
2
+
3
+
4
+ ### Features
5
+
6
+ * **wllama:** set SmolLM2 as default model and add aliases for smol and qwen ([0cf28a1](https://github.com/eliotstocker/Brsh-JS/commit/0cf28a1a57fc95dc6e90f86de5d9f4eb30e3d467))
7
+
1
8
  ## [3.3.1](https://github.com/eliotstocker/Brsh-JS/compare/v3.3.0...v3.3.1) (2026-11-09)
2
9
 
3
10
 
package/Readme.md CHANGED
@@ -327,8 +327,8 @@ wbt run jq -r ".name" package.json
327
327
  nano /home/hello.txt
328
328
 
329
329
  # Run Wllama v3 (llama.cpp WASM + WebGPU) for one-shot completions or interactive chat REPL!
330
- wllama -m /home/model.gguf -p "Explain WebGPU in one sentence."
331
- wllama pull https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories15M.gguf -o /home/model.gguf
330
+ wllama -p "Explain WebGPU in one sentence." # uses default SmolLM2 model (or pass -m qwen)
331
+ wllama pull smol -o /home/model.gguf
332
332
  wllama -m /home/model.gguf # launches interactive multi-turn chat REPL
333
333
 
334
334
  # Run SQLite3 (persists database files directly in the brsh filesystem, or run `sqlite3 /home/app.db` for interactive SQL REPL)
package/dist/wbt.es.js CHANGED
@@ -3810,15 +3810,32 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
3810
3810
  };
3811
3811
  })), oe = /* @__PURE__ */ t(((e, t) => {
3812
3812
  T();
3813
- var n = Z(), { readBytesFromFs: r, writeBytesToFs: i, loadModule: a } = ae(), o = "https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories260K.gguf", s = "https://cdn.jsdelivr.net/npm/@wllama/wllama@3.8.1/src/wasm/wllama.wasm", c = "/var/cache/wllama", l = /* @__PURE__ */ new Map();
3814
- function u(e) {
3815
- if (!e) return `${c}/model.gguf`;
3813
+ var n = Z(), { readBytesFromFs: r, writeBytesToFs: i, loadModule: a } = ae(), o = {
3814
+ smol: "https://huggingface.co/bartowski/SmolLM2-135M-Instruct-GGUF/resolve/main/SmolLM2-135M-Instruct-Q4_K_M.gguf",
3815
+ smollm: "https://huggingface.co/bartowski/SmolLM2-135M-Instruct-GGUF/resolve/main/SmolLM2-135M-Instruct-Q4_K_M.gguf",
3816
+ smollm2: "https://huggingface.co/bartowski/SmolLM2-135M-Instruct-GGUF/resolve/main/SmolLM2-135M-Instruct-Q4_K_M.gguf",
3817
+ "smol-135m": "https://huggingface.co/bartowski/SmolLM2-135M-Instruct-GGUF/resolve/main/SmolLM2-135M-Instruct-Q4_K_M.gguf",
3818
+ "smol-360m": "https://huggingface.co/bartowski/SmolLM2-360M-Instruct-GGUF/resolve/main/SmolLM2-360M-Instruct-Q4_K_M.gguf",
3819
+ "smollm-360m": "https://huggingface.co/bartowski/SmolLM2-360M-Instruct-GGUF/resolve/main/SmolLM2-360M-Instruct-Q4_K_M.gguf",
3820
+ "smollm2-360m": "https://huggingface.co/bartowski/SmolLM2-360M-Instruct-GGUF/resolve/main/SmolLM2-360M-Instruct-Q4_K_M.gguf",
3821
+ "smol-1.7b": "https://huggingface.co/bartowski/SmolLM2-1.7B-Instruct-GGUF/resolve/main/SmolLM2-1.7B-Instruct-Q4_K_M.gguf",
3822
+ qwen: "https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct-GGUF/resolve/main/qwen2.5-0.5b-instruct-q4_k_m.gguf",
3823
+ "qwen2.5": "https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct-GGUF/resolve/main/qwen2.5-0.5b-instruct-q4_k_m.gguf",
3824
+ "qwen-0.5b": "https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct-GGUF/resolve/main/qwen2.5-0.5b-instruct-q4_k_m.gguf",
3825
+ "qwen2.5-0.5b": "https://huggingface.co/Qwen/Qwen2.5-0.5B-Instruct-GGUF/resolve/main/qwen2.5-0.5b-instruct-q4_k_m.gguf",
3826
+ "qwen-1.5b": "https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct-GGUF/resolve/main/qwen2.5-1.5b-instruct-q4_k_m.gguf",
3827
+ "qwen2.5-1.5b": "https://huggingface.co/Qwen/Qwen2.5-1.5B-Instruct-GGUF/resolve/main/qwen2.5-1.5b-instruct-q4_k_m.gguf",
3828
+ stories: "https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories260K.gguf",
3829
+ stories15m: "https://huggingface.co/ggml-org/models/resolve/main/tinyllamas/stories15M.gguf"
3830
+ }, s = o.smol, c = "https://cdn.jsdelivr.net/npm/@wllama/wllama@3.8.1/src/wasm/wllama.wasm", l = "/var/cache/wllama", u = /* @__PURE__ */ new Map();
3831
+ function d(e) {
3832
+ if (!e) return `${l}/model.gguf`;
3816
3833
  if (e.kind === "fs") return e.path;
3817
- if (e.kind === "hf-quant") return `${c}/${(e.repo || "model").split("/").pop().replace(/[^a-zA-Z0-9._-]/g, "_")}-${(e.quant || "Q4_K_M").replace(/[^a-zA-Z0-9._-]/g, "_")}.gguf`;
3818
- let t = (e.file || e.url || o).split("/").pop().split("?")[0] || "model.gguf";
3819
- return /\.gguf$/i.test(t) || (t += ".gguf"), `${c}/${t}`;
3834
+ if (e.kind === "hf-quant") return `${l}/${(e.repo || "model").split("/").pop().replace(/[^a-zA-Z0-9._-]/g, "_")}-${(e.quant || "Q4_K_M").replace(/[^a-zA-Z0-9._-]/g, "_")}.gguf`;
3835
+ let t = (e.file || e.url || s).split("/").pop().split("?")[0] || "model.gguf";
3836
+ return /\.gguf$/i.test(t) || (t += ".gguf"), `${l}/${t}`;
3820
3837
  }
3821
- function d(e, t, n, r = 20) {
3838
+ function f(e, t, n, r = 20) {
3822
3839
  let i = (e) => e >= 1024 * 1024 ? `${(e / (1024 * 1024)).toFixed(1)} MB` : e >= 1024 ? `${(e / (1024 * 1024)).toFixed(1)} KB` : `${e} B`, a = (e || "model.gguf").split("/").pop().split("?")[0] || e;
3823
3840
  if (n > 0) {
3824
3841
  let e = Math.max(0, Math.min(1, t / n)), o = Math.round(e * 100), s = Math.round(e * r);
@@ -3826,7 +3843,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
3826
3843
  }
3827
3844
  return `\rPulling ${a}: ${i(t)} downloaded...`;
3828
3845
  }
3829
- function f(e, t = null, n = null, r = null) {
3846
+ function p(e, t = null, n = null, r = null) {
3830
3847
  if (t) {
3831
3848
  if (n) {
3832
3849
  let e = t.replace(/^hf:/i, "").replace(/^\/+|\/+$/g, ""), r = n.replace(/^\/+/, "");
@@ -3848,10 +3865,11 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
3848
3865
  let i = (e || "").trim();
3849
3866
  if (!i) return {
3850
3867
  kind: "url",
3851
- key: o,
3852
- url: o
3868
+ key: s,
3869
+ url: s
3853
3870
  };
3854
- if (/^hf:\/\//i.test(i) || /^hf:/i.test(i)) {
3871
+ let a = i.toLowerCase();
3872
+ if (o[a] && (i = o[a]), /^hf:\/\//i.test(i) || /^hf:/i.test(i)) {
3855
3873
  let e = i.replace(/^hf:(\/\/)?/i, ""), t = e.match(/^([^/]+\/[^/:]+):([^/]+)$/);
3856
3874
  if (t) return {
3857
3875
  kind: "hf-quant",
@@ -3887,7 +3905,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
3887
3905
  path: i
3888
3906
  };
3889
3907
  }
3890
- async function p(e, t) {
3908
+ async function m(e, t) {
3891
3909
  let n = await fetch(e);
3892
3910
  if (!n.ok) throw Error(`Failed to fetch model from ${e}: HTTP ${n.status}`);
3893
3911
  let r = Number(n.headers.get("content-length") || 0);
@@ -3912,8 +3930,8 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
3912
3930
  let s = new Blob(a, { type: "application/octet-stream" });
3913
3931
  return s.name = e.split("/").pop().split("?")[0] || "model.gguf", s;
3914
3932
  }
3915
- async function m({ wllama: e, mod: t, modelSpec: n, downloadedBlob: r = null, targetPersistPath: a, fs: s, progressCallback: c }) {
3916
- if (!s || !a) return null;
3933
+ async function h({ wllama: e, mod: t, modelSpec: n, downloadedBlob: r = null, targetPersistPath: a, fs: o, progressCallback: c }) {
3934
+ if (!o || !a) return null;
3917
3935
  let l = null;
3918
3936
  if (r && typeof r.arrayBuffer == "function") l = new Uint8Array(await r.arrayBuffer());
3919
3937
  else if (e && typeof e.getLoadedBlob == "function") {
@@ -3927,7 +3945,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
3927
3945
  }
3928
3946
  } catch {}
3929
3947
  if (!l) {
3930
- let e = n.url || (n.kind === "url" ? o : null);
3948
+ let e = n.url || (n.kind === "url" ? s : null);
3931
3949
  if (!e && n.kind === "hf-quant" && t && typeof t.getHFModelSource == "function") try {
3932
3950
  let r = await t.getHFModelSource({
3933
3951
  repo: n.repo,
@@ -3936,7 +3954,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
3936
3954
  e = r.url || r;
3937
3955
  } catch {}
3938
3956
  if (e && typeof fetch == "function") try {
3939
- let t = await p(e, c);
3957
+ let t = await m(e, c);
3940
3958
  l = new Uint8Array(await t.arrayBuffer());
3941
3959
  } catch {}
3942
3960
  }
@@ -3949,17 +3967,17 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
3949
3967
  0,
3950
3968
  0,
3951
3969
  0
3952
- ]), i(s, a, l, "application/octet-stream"), {
3970
+ ]), i(o, a, l, "application/octet-stream"), {
3953
3971
  path: a,
3954
3972
  size: l.byteLength
3955
3973
  };
3956
3974
  }
3957
- async function h(e = {}) {
3958
- let { modelSpec: t, mmprojSpec: n = null, loadParams: c = {}, fs: d, pkgMeta: f = {}, wbtConfig: h = {}, loadModel: g = !0, persist: _ = !1, persistPath: v = null, onStatus: y = null } = e;
3975
+ async function g(e = {}) {
3976
+ let { modelSpec: t, mmprojSpec: n = null, loadParams: o = {}, fs: l, pkgMeta: f = {}, wbtConfig: p = {}, loadModel: g = !0, persist: _ = !1, persistPath: v = null, onStatus: y = null } = e;
3959
3977
  typeof y == "function" && y("Initializing WASM runtime...");
3960
- let b = await a("@wllama/wllama", f.cdnUrl, h.moduleLoader), x = b.Wllama || b.default || b, S = b.LoggerWithoutDebug || void 0, C = f.wasmUrl || s;
3961
- if (f.wasmPath && d && typeof URL < "u" && typeof URL.createObjectURL == "function") {
3962
- let e = r(d, f.wasmPath);
3978
+ let b = await a("@wllama/wllama", f.cdnUrl, p.moduleLoader), x = b.Wllama || b.default || b, S = b.LoggerWithoutDebug || void 0, C = f.wasmUrl || c;
3979
+ if (f.wasmPath && l && typeof URL < "u" && typeof URL.createObjectURL == "function") {
3980
+ let e = r(l, f.wasmPath);
3963
3981
  e && e.byteLength > 0 && (C = URL.createObjectURL(new Blob([e], { type: "application/wasm" })));
3964
3982
  }
3965
3983
  let w = {
@@ -3994,25 +4012,25 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
3994
4012
  isCached: !1,
3995
4013
  persisted: null
3996
4014
  };
3997
- let E = v || (_ && t.kind !== "fs" ? u(t) : null), D = t.kind === "fs" ? null : u(t), O = t.kind === "fs" && d && typeof d.absolutePath == "function" ? `fs:${d.absolutePath(t.path)}:gpu=${c.n_gpu_layers ?? "auto"}:emb=${!!c.embeddings}` : `${t.key}:gpu=${c.n_gpu_layers ?? "auto"}:emb=${!!c.embeddings}`;
3998
- if (l.has(O)) {
3999
- let e = l.get(O);
4015
+ let E = v || (_ && t.kind !== "fs" ? d(t) : null), D = t.kind === "fs" ? null : d(t), O = t.kind === "fs" && l && typeof l.absolutePath == "function" ? `fs:${l.absolutePath(t.path)}:gpu=${o.n_gpu_layers ?? "auto"}:emb=${!!o.embeddings}` : `${t.key}:gpu=${o.n_gpu_layers ?? "auto"}:emb=${!!o.embeddings}`;
4016
+ if (u.has(O)) {
4017
+ let e = u.get(O);
4000
4018
  if (typeof e.isModelLoaded != "function" || e.isModelLoaded()) {
4001
4019
  typeof y == "function" && y("Loaded model from cache.");
4002
4020
  let n = null;
4003
- if ((_ || v) && d && E) if (d.exists(E)) {
4004
- let e = r(d, E);
4021
+ if ((_ || v) && l && E) if (l.exists(E)) {
4022
+ let e = r(l, E);
4005
4023
  n = {
4006
4024
  path: E,
4007
4025
  size: e ? e.byteLength : 0
4008
4026
  };
4009
- } else n = await m({
4027
+ } else n = await h({
4010
4028
  wllama: e,
4011
4029
  mod: b,
4012
4030
  modelSpec: t,
4013
4031
  targetPersistPath: E,
4014
- fs: d,
4015
- progressCallback: c.progressCallback
4032
+ fs: l,
4033
+ progressCallback: o.progressCallback
4016
4034
  });
4017
4035
  return {
4018
4036
  wllama: e,
@@ -4025,49 +4043,49 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4025
4043
  }
4026
4044
  }
4027
4045
  let k = T(), A = null, j = null;
4028
- if (t.kind !== "fs" && d) {
4029
- let e = E && d.exists(E) ? E : D && d.exists(D) ? D : null;
4046
+ if (t.kind !== "fs" && l) {
4047
+ let e = E && l.exists(E) ? E : D && l.exists(D) ? D : null;
4030
4048
  if (e) {
4031
- let t = r(d, e);
4049
+ let t = r(l, e);
4032
4050
  if (t && t.byteLength > 0) {
4033
4051
  typeof y == "function" && y(`Loading model from ${e}...`);
4034
4052
  let n = new Blob([t], { type: "application/octet-stream" });
4035
- n.name = e.split("/").pop() || "model.gguf", await k.loadModel([n], c), j = {
4053
+ n.name = e.split("/").pop() || "model.gguf", await k.loadModel([n], o), j = {
4036
4054
  path: e,
4037
4055
  bytes: t
4038
4056
  };
4039
4057
  }
4040
4058
  }
4041
4059
  }
4042
- if (j) E && E !== j.path && i(d, E, j.bytes, "application/octet-stream");
4060
+ if (j) E && E !== j.path && i(l, E, j.bytes, "application/octet-stream");
4043
4061
  else if (t.kind === "fs") {
4044
4062
  typeof y == "function" && y(`Loading model from ${t.path}...`);
4045
- let e = r(d, t.path);
4063
+ let e = r(l, t.path);
4046
4064
  if (!e) throw Error(`${t.path}: No such file or directory`);
4047
4065
  let a = new Blob([e], { type: "application/octet-stream" });
4048
4066
  a.name = t.path.split("/").pop() || "model.gguf";
4049
- let o = [a];
4067
+ let s = [a];
4050
4068
  if (n) {
4051
- let e = r(d, n);
4069
+ let e = r(l, n);
4052
4070
  if (!e) throw Error(`${n}: No such file or directory`);
4053
4071
  let t = new Blob([e], { type: "application/octet-stream" });
4054
- t.name = n.split("/").pop() || "mmproj.gguf", o.push(t);
4072
+ t.name = n.split("/").pop() || "mmproj.gguf", s.push(t);
4055
4073
  }
4056
- typeof y == "function" && y(`Loading model ${a.name} into memory...`), await k.loadModel(o, c), E && E !== t.path && i(d, E, e, "application/octet-stream");
4074
+ typeof y == "function" && y(`Loading model ${a.name} into memory...`), await k.loadModel(s, o), E && E !== t.path && i(l, E, e, "application/octet-stream");
4057
4075
  } else if (t.kind === "hf-quant" && typeof k.loadModelFromHF == "function") {
4058
4076
  typeof y == "function" && y(`Pulling model ${t.repo} (${t.quant})...`);
4059
4077
  try {
4060
4078
  await k.loadModelFromHF({
4061
4079
  repo: t.repo,
4062
4080
  quant: t.quant
4063
- }, c);
4081
+ }, o);
4064
4082
  } catch (e) {
4065
4083
  if (typeof b.getHFModelSource == "function") {
4066
4084
  let e = await b.getHFModelSource({
4067
4085
  repo: t.repo,
4068
4086
  quant: t.quant
4069
4087
  });
4070
- typeof y == "function" && y(`Pulling model ${t.repo} (${t.quant})...`), A = await p(e.url || e, c.progressCallback), typeof y == "function" && y("Loading model into memory..."), await k.loadModel([A], c);
4088
+ typeof y == "function" && y(`Pulling model ${t.repo} (${t.quant})...`), A = await m(e.url || e, o.progressCallback), typeof y == "function" && y("Loading model into memory..."), await k.loadModel([A], o);
4071
4089
  } else throw e;
4072
4090
  }
4073
4091
  } else if (t.kind === "hf-file" && typeof k.loadModelFromHF == "function") {
@@ -4076,20 +4094,20 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4076
4094
  await k.loadModelFromHF({
4077
4095
  repo: t.repo,
4078
4096
  file: t.file
4079
- }, c);
4097
+ }, o);
4080
4098
  } catch {
4081
- A = await p(t.url, c.progressCallback), typeof y == "function" && y("Loading model into memory..."), await k.loadModel([A], c);
4099
+ A = await m(t.url, o.progressCallback), typeof y == "function" && y("Loading model into memory..."), await k.loadModel([A], o);
4082
4100
  }
4083
4101
  } else {
4084
- let e = t.url || o;
4102
+ let e = t.url || s;
4085
4103
  typeof y == "function" && y(`Pulling model from ${e.split("/").pop().split("?")[0] || e}...`);
4086
4104
  try {
4087
4105
  n && /^https?:\/\//i.test(n) ? await k.loadModelFromUrl({
4088
4106
  url: e,
4089
4107
  mmprojUrl: n
4090
- }, c) : await k.loadModelFromUrl(e, c);
4108
+ }, o) : await k.loadModelFromUrl(e, o);
4091
4109
  } catch {
4092
- A = await p(e, c.progressCallback), typeof y == "function" && y("Loading model into memory..."), await k.loadModel([A], c);
4110
+ A = await m(e, o.progressCallback), typeof y == "function" && y("Loading model into memory..."), await k.loadModel([A], o);
4093
4111
  }
4094
4112
  }
4095
4113
  typeof y == "function" && y("Model loaded.");
@@ -4097,15 +4115,15 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4097
4115
  return j ? M = {
4098
4116
  path: E || j.path,
4099
4117
  size: j.bytes.byteLength
4100
- } : (_ || v) && d && E && t.kind !== "fs" && (M = await m({
4118
+ } : (_ || v) && l && E && t.kind !== "fs" && (M = await h({
4101
4119
  wllama: k,
4102
4120
  mod: b,
4103
4121
  modelSpec: t,
4104
4122
  downloadedBlob: A,
4105
4123
  targetPersistPath: E,
4106
- fs: d,
4107
- progressCallback: c.progressCallback
4108
- })), l.set(O, k), {
4124
+ fs: l,
4125
+ progressCallback: o.progressCallback
4126
+ })), u.set(O, k), {
4109
4127
  wllama: k,
4110
4128
  mod: b,
4111
4129
  Wllama: x,
@@ -4114,7 +4132,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4114
4132
  persisted: M
4115
4133
  };
4116
4134
  }
4117
- function g(e) {
4135
+ function _(e) {
4118
4136
  if (typeof e == "string") return e;
4119
4137
  if (!e || typeof e != "object") return "";
4120
4138
  if (Array.isArray(e.choices) && e.choices.length > 0) {
@@ -4125,7 +4143,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4125
4143
  }
4126
4144
  return typeof e.content == "string" ? e.content : typeof e.text == "string" ? e.text : "";
4127
4145
  }
4128
- function _(e = {}, t = {}, i = "wllama") {
4146
+ function v(e = {}, t = {}, i = "wllama") {
4129
4147
  class a extends n {
4130
4148
  static get name() {
4131
4149
  return i;
@@ -4140,22 +4158,22 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4140
4158
  });
4141
4159
  }
4142
4160
  _parseArgs(e) {
4143
- let t = null, n = null, r = null, i = null, a = null, o = null, s = null, c = null, l = 256, u = .7, d, p, m = 4096, h, g, _, v = !1, y = !1, b = !1, x = !0, S = !0, C = !1, w = null, T = !0, E = !1, D = !1, O = null, k = [], A = [];
4144
- for (let f = 0; f < e.length; f++) {
4145
- let j = e[f];
4146
- if (j === "--help" || j === "-h" && f + 1 >= e.length || j === "-?") E = !0;
4147
- else if (j === "--version" || j === "-V" || j === "-v") D = !0;
4148
- else if (j === "--serve" || j === "--daemon") O = "serve";
4149
- else if (j === "-q" || j === "--quiet" || j === "--no-progress") T = !1;
4150
- else if (j === "--progress") T = !0;
4151
- else if (j === "--persist" || j === "--save") {
4152
- C = !0;
4153
- let n = e[f + 1];
4154
- n && !n.startsWith("-") && !/^https?:\/\//i.test(n) && !/^hf:/i.test(n) && (n.startsWith("/") || n.startsWith("./") || n.startsWith("../") || /\.gguf$/i.test(n)) && (t !== null || r !== null || f + 2 < e.length || O === "pull") && (t !== null || r !== null) && (w = e[++f]);
4155
- } else j.startsWith("--persist=") ? (C = !0, w = j.slice(10) || null) : j.startsWith("--save=") ? (C = !0, w = j.slice(7) || null) : (j === "-o" || j === "--output") && f + 1 < e.length ? (C = !0, w = e[++f]) : j.startsWith("--output=") ? (C = !0, w = j.slice(9) || null) : (j === "-m" || j === "--model" || j === "--url") && f + 1 < e.length ? t = e[++f] : j.startsWith("--model=") ? t = j.slice(8) : j === "--mmproj" && f + 1 < e.length ? n = e[++f] : (j === "--hf" || j === "-hf" || j === "--hf-repo") && f + 1 < e.length ? r = e[++f] : j === "--hf-file" && f + 1 < e.length ? i = e[++f] : (j === "--quant" || j === "--hf-quant") && f + 1 < e.length ? a = e[++f] : (j === "-p" || j === "--prompt") && f + 1 < e.length ? o = e[++f] : j.startsWith("--prompt=") ? o = j.slice(9) : (j === "-f" || j === "--file") && f + 1 < e.length ? s = e[++f] : (j === "-s" || j === "--system" || j === "--system-prompt") && f + 1 < e.length ? c = e[++f] : (j === "-n" || j === "--n-predict" || j === "--max-tokens") && f + 1 < e.length ? l = Number(e[++f]) || 256 : (j === "--temp" || j === "--temperature") && f + 1 < e.length ? u = Number(e[++f]) : (j === "--top-k" || j === "--top_k") && f + 1 < e.length ? d = Number(e[++f]) : (j === "--top-p" || j === "--top_p") && f + 1 < e.length ? p = Number(e[++f]) : (j === "-c" || j === "--ctx-size" || j === "--n-ctx") && f + 1 < e.length ? m = Number(e[++f]) || 4096 : (j === "-b" || j === "--batch-size") && f + 1 < e.length ? h = Number(e[++f]) : (j === "-t" || j === "--threads") && f + 1 < e.length ? g = Number(e[++f]) : (j === "-ngl" || j === "--n-gpu-layers" || j === "--gpu-layers") && f + 1 < e.length ? _ = Number(e[++f]) : j === "--no-gpu" || j === "--cpu" ? _ = 0 : j === "--webgpu" || j === "--gpu" ? (_ === void 0 || _ === 0) && (_ = 99) : j === "--embeddings" || j === "--embedding" || j === "--embed" ? (v = !0, O ||= "embed") : j === "--raw" || j === "--completion" ? y = !0 : j === "--stream" ? x = !0 : j === "--no-stream" ? x = !1 : j === "--json" ? b = !0 : j === "--no-jinja" ? S = !1 : j.startsWith("-") ? k.push(j) : A.push(j);
4161
+ let t = null, n = null, r = null, i = null, a = null, s = null, c = null, l = null, u = 256, d = .7, f, m, h = 4096, g, _, v, y = !1, b = !1, x = !1, S = !0, C = !0, w = !1, T = null, E = !0, D = !1, O = !1, k = null, A = [], j = [];
4162
+ for (let o = 0; o < e.length; o++) {
4163
+ let p = e[o];
4164
+ if (p === "--help" || p === "-h" && o + 1 >= e.length || p === "-?") D = !0;
4165
+ else if (p === "--version" || p === "-V" || p === "-v") O = !0;
4166
+ else if (p === "--serve" || p === "--daemon") k = "serve";
4167
+ else if (p === "-q" || p === "--quiet" || p === "--no-progress") E = !1;
4168
+ else if (p === "--progress") E = !0;
4169
+ else if (p === "--persist" || p === "--save") {
4170
+ w = !0;
4171
+ let n = e[o + 1];
4172
+ n && !n.startsWith("-") && !/^https?:\/\//i.test(n) && !/^hf:/i.test(n) && (n.startsWith("/") || n.startsWith("./") || n.startsWith("../") || /\.gguf$/i.test(n)) && (t !== null || r !== null || o + 2 < e.length || k === "pull") && (t !== null || r !== null) && (T = e[++o]);
4173
+ } else p.startsWith("--persist=") ? (w = !0, T = p.slice(10) || null) : p.startsWith("--save=") ? (w = !0, T = p.slice(7) || null) : (p === "-o" || p === "--output") && o + 1 < e.length ? (w = !0, T = e[++o]) : p.startsWith("--output=") ? (w = !0, T = p.slice(9) || null) : (p === "-m" || p === "--model" || p === "--url") && o + 1 < e.length ? t = e[++o] : p.startsWith("--model=") ? t = p.slice(8) : p === "--mmproj" && o + 1 < e.length ? n = e[++o] : (p === "--hf" || p === "-hf" || p === "--hf-repo") && o + 1 < e.length ? r = e[++o] : p === "--hf-file" && o + 1 < e.length ? i = e[++o] : (p === "--quant" || p === "--hf-quant") && o + 1 < e.length ? a = e[++o] : (p === "-p" || p === "--prompt") && o + 1 < e.length ? s = e[++o] : p.startsWith("--prompt=") ? s = p.slice(9) : (p === "-f" || p === "--file") && o + 1 < e.length ? c = e[++o] : (p === "-s" || p === "--system" || p === "--system-prompt") && o + 1 < e.length ? l = e[++o] : (p === "-n" || p === "--n-predict" || p === "--max-tokens") && o + 1 < e.length ? u = Number(e[++o]) || 256 : (p === "--temp" || p === "--temperature") && o + 1 < e.length ? d = Number(e[++o]) : (p === "--top-k" || p === "--top_k") && o + 1 < e.length ? f = Number(e[++o]) : (p === "--top-p" || p === "--top_p") && o + 1 < e.length ? m = Number(e[++o]) : (p === "-c" || p === "--ctx-size" || p === "--n-ctx") && o + 1 < e.length ? h = Number(e[++o]) || 4096 : (p === "-b" || p === "--batch-size") && o + 1 < e.length ? g = Number(e[++o]) : (p === "-t" || p === "--threads") && o + 1 < e.length ? _ = Number(e[++o]) : (p === "-ngl" || p === "--n-gpu-layers" || p === "--gpu-layers") && o + 1 < e.length ? v = Number(e[++o]) : p === "--no-gpu" || p === "--cpu" ? v = 0 : p === "--webgpu" || p === "--gpu" ? (v === void 0 || v === 0) && (v = 99) : p === "--embeddings" || p === "--embedding" || p === "--embed" ? (y = !0, k ||= "embed") : p === "--raw" || p === "--completion" ? b = !0 : p === "--stream" ? S = !0 : p === "--no-stream" ? S = !1 : p === "--json" ? x = !0 : p === "--no-jinja" ? C = !1 : p.startsWith("-") ? A.push(p) : j.push(p);
4156
4174
  }
4157
- if (A.length > 0) {
4158
- let e = A[0].toLowerCase();
4175
+ if (j.length > 0) {
4176
+ let e = j[0].toLowerCase();
4159
4177
  if ([
4160
4178
  "info",
4161
4179
  "models",
@@ -4170,45 +4188,45 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4170
4188
  "pull",
4171
4189
  "download"
4172
4190
  ].includes(e)) {
4173
- let e = A.shift().toLowerCase();
4174
- e === "list" ? O = "models" : e === "embeddings" ? (O = "embed", v = !0) : e === "test-ops" ? O = "bench" : e === "completion" ? (O = "run", y = !0) : e === "download" || e === "pull" ? (O = "pull", C = !0) : O = e;
4191
+ let e = j.shift().toLowerCase();
4192
+ e === "list" ? k = "models" : e === "embeddings" ? (k = "embed", y = !0) : e === "test-ops" ? k = "bench" : e === "completion" ? (k = "run", b = !0) : e === "download" || e === "pull" ? (k = "pull", w = !0) : k = e;
4175
4193
  }
4176
4194
  }
4177
- if (A.length > 0 && (!t && !r && (O === "pull" || /\.gguf(\?.*)?$/i.test(A[0]) || /^hf:/i.test(A[0]) || /^https?:\/\//i.test(A[0])) && (t = A.shift()), O === "pull" && A.length > 0 && !w ? w = A.shift() : A.length > 0 && o === null && (o = A.join(" "))), !t && !r && this.context && typeof this.context.getVar == "function") {
4195
+ if (j.length > 0 && (!t && !r && (k === "pull" || o[j[0].toLowerCase()] || /\.gguf(\?.*)?$/i.test(j[0]) || /^hf:/i.test(j[0]) || /^https?:\/\//i.test(j[0])) && (t = j.shift()), k === "pull" && j.length > 0 && !T ? T = j.shift() : j.length > 0 && s === null && (s = j.join(" "))), !t && !r && this.context && typeof this.context.getVar == "function") {
4178
4196
  let e = this.context.getVar("WLLAMA_MODEL");
4179
4197
  e && (t = e);
4180
4198
  }
4181
- let j = f(t, r, i, a), M = {
4182
- n_ctx: m,
4183
- jinja: S
4199
+ let M = p(t, r, i, a), N = {
4200
+ n_ctx: h,
4201
+ jinja: C
4184
4202
  };
4185
- return _ !== void 0 && (M.n_gpu_layers = _), h !== void 0 && (M.n_batch = h), g !== void 0 && (M.n_threads = g), v && (M.embeddings = !0), {
4203
+ return v !== void 0 && (N.n_gpu_layers = v), g !== void 0 && (N.n_batch = g), _ !== void 0 && (N.n_threads = _), y && (N.embeddings = !0), {
4186
4204
  model: t,
4187
4205
  mmproj: n,
4188
- modelSpec: j,
4189
- loadParams: M,
4190
- prompt: o,
4191
- file: s,
4192
- systemPrompt: c,
4193
- maxTokens: l,
4194
- temperature: u,
4195
- topK: d,
4196
- topP: p,
4197
- nCtx: m,
4198
- nGpuLayers: _,
4199
- embeddings: v,
4200
- rawCompletion: y,
4201
- jsonOutput: b,
4202
- stream: x,
4203
- persist: C,
4204
- persistPath: w,
4205
- showProgress: T,
4206
- help: E,
4207
- version: D,
4208
- subcommand: O,
4206
+ modelSpec: M,
4207
+ loadParams: N,
4208
+ prompt: s,
4209
+ file: c,
4210
+ systemPrompt: l,
4211
+ maxTokens: u,
4212
+ temperature: d,
4213
+ topK: f,
4214
+ topP: m,
4215
+ nCtx: h,
4216
+ nGpuLayers: v,
4217
+ embeddings: y,
4218
+ rawCompletion: b,
4219
+ jsonOutput: x,
4220
+ stream: S,
4221
+ persist: w,
4222
+ persistPath: T,
4223
+ showProgress: E,
4224
+ help: D,
4225
+ version: O,
4226
+ subcommand: k,
4209
4227
  host: "127.0.0.1",
4210
4228
  port: 8080,
4211
- extraArgs: k
4229
+ extraArgs: A
4212
4230
  };
4213
4231
  }
4214
4232
  shouldBeInteractive() {
@@ -4242,14 +4260,14 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4242
4260
  let i = Date.now();
4243
4261
  if (t === 0 || r > 0 && n >= r || i - t >= 40) {
4244
4262
  t = i;
4245
- let a = d(e, n, r);
4263
+ let a = f(e, n, r);
4246
4264
  this.interactive ? (this._replStatus = a.replace(/^\r/, ""), this._renderRepl()) : this._parsed.subcommand === "pull" ? (this.stdOut = a, this.flush()) : this._renderStatus(a.replace(/^\r/, ""));
4247
4265
  }
4248
4266
  };
4249
4267
  }
4250
4268
  async _initWllama(n = !0) {
4251
4269
  n && this._attachProgressCallback();
4252
- let { wllama: r, Wllama: i, persisted: a } = await h({
4270
+ let { wllama: r, Wllama: i, persisted: a } = await g({
4253
4271
  modelSpec: this._parsed.modelSpec,
4254
4272
  mmprojSpec: this._parsed.mmproj,
4255
4273
  loadParams: this._parsed.loadParams,
@@ -4333,7 +4351,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4333
4351
  return this.interactive || this._clearStatus(), n;
4334
4352
  }
4335
4353
  if (this._parsed.jsonOutput) return this.interactive || this._clearStatus(), JSON.stringify(e);
4336
- let n = g(e);
4354
+ let n = _(e);
4337
4355
  return this.interactive || this._clearStatus(), typeof t == "function" && n && t(n), n;
4338
4356
  }
4339
4357
  let i = {
@@ -4353,7 +4371,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4353
4371
  return this.interactive || this._clearStatus(), e;
4354
4372
  }
4355
4373
  if (this.interactive || this._clearStatus(), this._parsed.jsonOutput) return JSON.stringify(a);
4356
- let o = g(a);
4374
+ let o = _(a);
4357
4375
  return typeof t == "function" && o && t(o), o;
4358
4376
  }
4359
4377
  _formatModelInfo() {
@@ -4371,7 +4389,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4371
4389
  if (this._parsed.port, e === "pull") {
4372
4390
  try {
4373
4391
  await this._initWllama(!0);
4374
- let e = this._persisted && this._persisted.path || this._parsed.persistPath || u(this._parsed.modelSpec), t = this._persisted && this._persisted.size || 0, n = t >= 1024 * 1024 ? `${(t / (1024 * 1024)).toFixed(1)} MB` : `${t} B`;
4392
+ let e = this._persisted && this._persisted.path || this._parsed.persistPath || d(this._parsed.modelSpec), t = this._persisted && this._persisted.size || 0, n = t >= 1024 * 1024 ? `${(t / (1024 * 1024)).toFixed(1)} MB` : `${t} B`;
4375
4393
  this.stdOut = `Persisted model ${this._parsed.model || this._parsed.modelSpec.key} -> ${e} (${n})`;
4376
4394
  } catch (e) {
4377
4395
  this.stdErr = `wllama: could not pull model: ${e.message || e}`, this.exitCode = 1;
@@ -4388,22 +4406,22 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4388
4406
  let e = [];
4389
4407
  this._wllama && this._wllama.modelManager && typeof this._wllama.modelManager.getModels == "function" && (e = await this._wllama.modelManager.getModels());
4390
4408
  let t = [];
4391
- if (this.fs && typeof this.fs.exists == "function" && this.fs.exists(c)) {
4392
- let e = typeof this.fs.getFileByPath == "function" ? this.fs.getFileByPath(c) : null;
4409
+ if (this.fs && typeof this.fs.exists == "function" && this.fs.exists(l)) {
4410
+ let e = typeof this.fs.getFileByPath == "function" ? this.fs.getFileByPath(l) : null;
4393
4411
  if (e && typeof e == "object") for (let n of Object.keys(e)) {
4394
- let e = `${c}/${n}`, i = r(this.fs, e);
4412
+ let e = `${l}/${n}`, i = r(this.fs, e);
4395
4413
  t.push({
4396
4414
  path: e,
4397
4415
  size: i ? i.byteLength : 0
4398
4416
  });
4399
4417
  }
4400
4418
  }
4401
- if (e.length === 0 && l.size === 0 && t.length === 0) {
4419
+ if (e.length === 0 && u.size === 0 && t.length === 0) {
4402
4420
  this.stdOut = "No cached models found.";
4403
4421
  return;
4404
4422
  }
4405
4423
  this.stdOut = "MODEL SIZE STATUS";
4406
- for (let [e] of l.entries()) this.stdOut = `${e.split(":gpu=")[0].padEnd(54)} in-memory loaded`;
4424
+ for (let [e] of u.entries()) this.stdOut = `${e.split(":gpu=")[0].padEnd(54)} in-memory loaded`;
4407
4425
  for (let e of t) {
4408
4426
  let t = e.size >= 1024 * 1024 ? `${(e.size / (1024 * 1024)).toFixed(1)} MB` : `${e.size} B`;
4409
4427
  this.stdOut = `${e.path.padEnd(54)} ${t.padEnd(11)} persisted (fs)`;
@@ -4434,7 +4452,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4434
4452
  " wllama bench Run ggml WebGPU/CPU backend ops test",
4435
4453
  "",
4436
4454
  "Options:",
4437
- " -m, --model=MODEL Path in brsh filesystem, URL, or hf:owner/repo/file.gguf",
4455
+ " -m, --model=MODEL Path in brsh fs, URL, HF spec, or alias (default: smol [SmolLM2-135M]; also: qwen)",
4438
4456
  " --hf=REPO Hugging Face model repository (e.g. Qwen/Qwen2.5-0.5B-Instruct-GGUF)",
4439
4457
  " --quant=QUANT Hugging Face GGUF quantization (default: Q4_K_M)",
4440
4458
  " --persist[=PATH] Persist pulled remote model into brsh filesystem (default: /var/cache/wllama/)",
@@ -4510,7 +4528,7 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4510
4528
  n && (e || (e = !0, this._streamedStdout = !0, this._clearStatus()), i += n, this.stdout && typeof this.stdout.write == "function" && this.stdout.write(n), this.emit("token", n));
4511
4529
  }
4512
4530
  this._clearStatus(), e && i.length > 0 && !i.endsWith("\n") && this.stdout && typeof this.stdout.write == "function" && this.stdout.write("\r\n");
4513
- } else this._clearStatus(), i = this._parsed.jsonOutput ? JSON.stringify(r) : g(r);
4531
+ } else this._clearStatus(), i = this._parsed.jsonOutput ? JSON.stringify(r) : _(r);
4514
4532
  i.split(/\r?\n/).forEach((e) => {
4515
4533
  this.stdOut = e;
4516
4534
  });
@@ -4541,26 +4559,26 @@ var R, z, B, V, H, U, W, G, K, q, ee = e((() => {
4541
4559
  }
4542
4560
  return a;
4543
4561
  }
4544
- function v(e = {}, t = {}) {
4562
+ function y(e = {}, t = {}) {
4545
4563
  return [
4546
4564
  {
4547
4565
  bin: (e.bin || "wllama").toLowerCase(),
4548
- Cmd: _(e, t, "wllama")
4566
+ Cmd: v(e, t, "wllama")
4549
4567
  },
4550
4568
  {
4551
4569
  bin: "llama",
4552
- Cmd: _(e, t, "llama")
4570
+ Cmd: v(e, t, "llama")
4553
4571
  },
4554
4572
  {
4555
4573
  bin: "llama-cli",
4556
- Cmd: _(e, t, "llama-cli")
4574
+ Cmd: v(e, t, "llama-cli")
4557
4575
  }
4558
4576
  ];
4559
4577
  }
4560
- t.exports = _, t.exports.createWllamaCommand = _, t.exports.buildEntries = v, t.exports.WllamaCommand = _({
4578
+ t.exports = v, t.exports.createWllamaCommand = v, t.exports.buildEntries = y, t.exports.WllamaCommand = v({
4561
4579
  name: "wllama",
4562
4580
  version: "3.8.1"
4563
- }), t.exports.wllamaInstances = l, t.exports.getDefaultPersistPath = u, t.exports.DEFAULT_PERSIST_DIR = c, t.exports.resolveModelSpec = f, t.exports.formatDownloadProgress = d;
4581
+ }), t.exports.wllamaInstances = u, t.exports.getDefaultPersistPath = d, t.exports.DEFAULT_PERSIST_DIR = l, t.exports.resolveModelSpec = p, t.exports.formatDownloadProgress = f, t.exports.DEFAULT_MODEL_URL = s, t.exports.MODEL_ALIASES = o;
4564
4582
  })), se = /* @__PURE__ */ t(((e, t) => {
4565
4583
  b();
4566
4584
  var r = E(), i = X(), a = Z(), { DEFAULT_REGISTRY: o, resolvePackageName: s } = ie(), c = oe(), { writeBytesToFs: l, createGenericWasmCommand: u } = i, { createReplWasmCommand: d } = a, f = "/var/lib/wbt/installed.json", p = "/var/cache/wbt";