brsh 3.10.3 → 3.10.5

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,17 @@
1
+ ## [3.10.5](https://github.com/eliotstocker/Brsh-JS/compare/v3.10.4...v3.10.5) (2026-11-27)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **wbt:** prevent wllama status clear from erasing streamed tokens ([7c882e2](https://github.com/eliotstocker/Brsh-JS/commit/7c882e2007ef3be0c621a5d001e75b5cf40af1c7))
7
+
8
+ ## [3.10.4](https://github.com/eliotstocker/Brsh-JS/compare/v3.10.3...v3.10.4) (2026-11-26)
9
+
10
+
11
+ ### Bug Fixes
12
+
13
+ * **wbt:** avoid __dirname in browser bundle for wllama, add pico alias and vim package ([11ad8ec](https://github.com/eliotstocker/Brsh-JS/commit/11ad8ec1af42584aaea2299e153084b42151060e))
14
+
1
15
  ## [3.10.3](https://github.com/eliotstocker/Brsh-JS/compare/v3.10.2...v3.10.3) (2026-11-11)
2
16
 
3
17
 
package/dist/wbt.es.js CHANGED
@@ -4567,7 +4567,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4567
4567
  nano: {
4568
4568
  name: "nano",
4569
4569
  bin: "nano",
4570
- aliases: ["nano-wasm"],
4570
+ aliases: ["nano-wasm", "pico"],
4571
4571
  version: "8.0.1",
4572
4572
  description: "GNU nano 8.0 text editor compiled to WebAssembly (wasm32-wasip1) with ncurses",
4573
4573
  details: "GNU nano is a small, user-friendly command-line text editor compiled to WebAssembly with wide-character ncurses 6.5, built-in terminfo fallbacks (xterm-256color, vt100, etc.), dynamic terminal dimensions (TIOCGWINSZ / LINES & COLUMNS), and zero custom imports (standard wasi_snapshot_preview1).",
@@ -4578,6 +4578,20 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4578
4578
  interactive: !0,
4579
4579
  size: "680 KB"
4580
4580
  },
4581
+ vim: {
4582
+ name: "vim",
4583
+ bin: "vim",
4584
+ aliases: ["vi", "vim-wasm"],
4585
+ version: "9.1.0700",
4586
+ description: "Vim 9.1 text editor compiled to WebAssembly (wasm32-wasip1) with ncurses",
4587
+ details: "Vim 9.1 (9.1.0700) compiled to WebAssembly (wasm32-wasip1) with static ncursesw 6.5, built-in terminfo fallbacks (xterm-256color, vt100, etc.), Asyncify interactive I/O, built-in defaults.vim fallback, and zero custom imports (standard wasi_snapshot_preview1).",
4588
+ homepage: "https://github.com/eliotstocker/vim-wasm",
4589
+ cdnUrl: "https://cdn.jsdelivr.net/gh/eliotstocker/vim-wasm@main/dist/vim.wasm",
4590
+ wasmUrl: "https://cdn.jsdelivr.net/gh/eliotstocker/vim-wasm@main/dist/vim.wasm",
4591
+ type: "custom-wasm",
4592
+ interactive: !0,
4593
+ size: "4.5 MB"
4594
+ },
4581
4595
  doom: {
4582
4596
  name: "doom",
4583
4597
  bin: "doom",
@@ -4611,6 +4625,9 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4611
4625
  "llama.cpp": "wllama",
4612
4626
  "@wllama/wllama": "wllama",
4613
4627
  "nano-wasm": "nano",
4628
+ pico: "nano",
4629
+ vi: "vim",
4630
+ "vim-wasm": "vim",
4614
4631
  "doom-wasm": "doom",
4615
4632
  "doom-ascii": "doom",
4616
4633
  freedoom: "doom"
@@ -4745,7 +4762,8 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
4745
4762
  typeof this.onRender == "function" && this.onRender(i), this.active = !1;
4746
4763
  }
4747
4764
  clear() {
4748
- this.stopTimer(), this.active = !1, this.enabled && typeof this.onRender == "function" && this.onRender("");
4765
+ let e = this.active;
4766
+ this.stopTimer(), this.active = !1, e && this.enabled && typeof this.onRender == "function" && this.onRender("");
4749
4767
  }
4750
4768
  };
4751
4769
  function h(e, t = null, n = null, r = null) {
@@ -5312,42 +5330,43 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
5312
5330
  this._parsed.topK !== void 0 && (r.top_k = this._parsed.topK), this._parsed.topP !== void 0 && (r.top_p = this._parsed.topP);
5313
5331
  let i = this._createTracker();
5314
5332
  i.start("Running inference", { hint: "evaluating prompt & preparing KV cache" });
5333
+ let a = !1;
5315
5334
  try {
5316
5335
  if (typeof this._wllama.createChatCompletion == "function") {
5317
5336
  let e = await this._wllama.createChatCompletion(r);
5318
5337
  if (e && typeof e[Symbol.asyncIterator] == "function") {
5319
- let n = "", r = !1;
5320
- for await (let a of e) {
5321
- let e = a?.choices?.[0]?.delta?.content ?? a?.choices?.[0]?.text ?? "";
5322
- e && (r || (r = !0, i.clear(), this.interactive ? (this._replStatus = "Streaming tokens...", this._renderRepl()) : this._clearStatus()), n += e, typeof t == "function" && t(e));
5338
+ let n = "";
5339
+ for await (let r of e) {
5340
+ let e = r?.choices?.[0]?.delta?.content ?? r?.choices?.[0]?.text ?? "";
5341
+ e && (a || (a = !0, i.clear(), this.interactive && (this._replStatus = "Streaming tokens...", this._renderRepl())), n += e, typeof t == "function" && t(e));
5323
5342
  }
5324
- return i.clear(), this.interactive || this._clearStatus(), n;
5343
+ return i.clear(), !this.interactive && !a && this._clearStatus(), n;
5325
5344
  }
5326
5345
  if (i.clear(), this.interactive || this._clearStatus(), this._parsed.jsonOutput) return JSON.stringify(e);
5327
5346
  let n = y(e);
5328
5347
  return typeof t == "function" && n && t(n), n;
5329
5348
  }
5330
- let a = {
5349
+ let o = {
5331
5350
  prompt: e[e.length - 1]?.content || "",
5332
5351
  max_tokens: this._parsed.maxTokens,
5333
5352
  temperature: this._parsed.temperature,
5334
5353
  stream: n
5335
5354
  };
5336
- this._parsed.topK !== void 0 && (a.top_k = this._parsed.topK), this._parsed.topP !== void 0 && (a.top_p = this._parsed.topP);
5337
- let o = await this._wllama.createCompletion(a);
5338
- if (o && typeof o[Symbol.asyncIterator] == "function") {
5339
- let e = "", n = !1;
5340
- for await (let r of o) {
5341
- let a = r?.choices?.[0]?.text ?? r?.choices?.[0]?.delta?.content ?? "";
5342
- a && (n || (n = !0, i.clear(), this.interactive ? (this._replStatus = "Streaming tokens...", this._renderRepl()) : this._clearStatus()), e += a, typeof t == "function" && t(a));
5355
+ this._parsed.topK !== void 0 && (o.top_k = this._parsed.topK), this._parsed.topP !== void 0 && (o.top_p = this._parsed.topP);
5356
+ let s = await this._wllama.createCompletion(o);
5357
+ if (s && typeof s[Symbol.asyncIterator] == "function") {
5358
+ let e = "";
5359
+ for await (let n of s) {
5360
+ let r = n?.choices?.[0]?.text ?? n?.choices?.[0]?.delta?.content ?? "";
5361
+ r && (a || (a = !0, i.clear(), this.interactive && (this._replStatus = "Streaming tokens...", this._renderRepl())), e += r, typeof t == "function" && t(r));
5343
5362
  }
5344
- return i.clear(), this.interactive || this._clearStatus(), e;
5363
+ return i.clear(), !this.interactive && !a && this._clearStatus(), e;
5345
5364
  }
5346
- if (i.clear(), this.interactive || this._clearStatus(), this._parsed.jsonOutput) return JSON.stringify(o);
5347
- let s = y(o);
5348
- return typeof t == "function" && s && t(s), s;
5365
+ if (i.clear(), this.interactive || this._clearStatus(), this._parsed.jsonOutput) return JSON.stringify(s);
5366
+ let c = y(s);
5367
+ return typeof t == "function" && c && t(c), c;
5349
5368
  } finally {
5350
- i.clear(), this.interactive || this._clearStatus();
5369
+ i.clear(), !this.interactive && !a && this._clearStatus();
5351
5370
  }
5352
5371
  }
5353
5372
  _formatModelInfo() {
@@ -5505,22 +5524,22 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
5505
5524
  this._parsed.topK !== void 0 && (n.top_k = this._parsed.topK), this._parsed.topP !== void 0 && (n.top_p = this._parsed.topP);
5506
5525
  let r = this._createTracker();
5507
5526
  r.start("Running inference", { hint: "evaluating prompt & preparing KV cache" });
5527
+ let i = !1;
5508
5528
  try {
5509
5529
  let e = await this._wllama.createCompletion(n), t = "";
5510
5530
  if (e && typeof e[Symbol.asyncIterator] == "function") {
5511
- let n = !1;
5512
- for await (let i of e) {
5513
- let e = i?.choices?.[0]?.text ?? i?.choices?.[0]?.delta?.content ?? "";
5514
- e && (n || (n = !0, this._streamedStdout = !0, r.clear(), this._clearStatus()), t += e, this.stdout && typeof this.stdout.write == "function" && this.stdout.write(e), this.emit("token", e));
5531
+ for await (let n of e) {
5532
+ let e = n?.choices?.[0]?.text ?? n?.choices?.[0]?.delta?.content ?? "";
5533
+ e && (i || (i = !0, this._streamedStdout = !0, r.clear()), t += e, this.stdout && typeof this.stdout.write == "function" && this.stdout.write(e), this.emit("token", e));
5515
5534
  }
5516
- r.clear(), this._clearStatus(), n && t.length > 0 && !t.endsWith("\n") && this.stdout && typeof this.stdout.write == "function" && this.stdout.write("\r\n");
5535
+ r.clear(), i || this._clearStatus(), i && t.length > 0 && !t.endsWith("\n") && this.stdout && typeof this.stdout.write == "function" && this.stdout.write("\r\n");
5517
5536
  } else r.clear(), this._clearStatus(), t = this._parsed.jsonOutput ? JSON.stringify(e) : y(e);
5518
5537
  t.split(/\r?\n/).forEach((e) => {
5519
5538
  this.stdOut = e;
5520
5539
  });
5521
5540
  return;
5522
5541
  } finally {
5523
- r.clear(), this._clearStatus();
5542
+ r.clear(), i || this._clearStatus();
5524
5543
  }
5525
5544
  }
5526
5545
  let t = [];
@@ -5570,7 +5589,9 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
5570
5589
  }), t.exports.wllamaInstances = u, t.exports.getDefaultPersistPath = d, t.exports.DEFAULT_PERSIST_DIR = l, t.exports.resolveModelSpec = h, t.exports.formatDownloadProgress = p, t.exports.DEFAULT_MODEL_URL = s, t.exports.MODEL_ALIASES = o;
5571
5590
  })), ce = /* @__PURE__ */ t(((e, t) => {
5572
5591
  b();
5573
- var r = B(), i = W(), a = X(), o = K(), { DEFAULT_REGISTRY: s, resolvePackageName: c } = oe(), l = se(), { writeBytesToFs: u, createGenericWasmCommand: d } = a, { createReplWasmCommand: f } = o, p = "/var/cache/wbt";
5592
+ var r = B(), i = W(), a = X(), o = K(), { DEFAULT_REGISTRY: s, resolvePackageName: c } = oe(), l = se();
5593
+ typeof globalThis < "u" && (globalThis.__brshWllamaAdapter = l);
5594
+ var { writeBytesToFs: u, createGenericWasmCommand: d } = a, { createReplWasmCommand: f } = o, p = "/var/cache/wbt";
5574
5595
  function m(e, t, n = {}) {
5575
5596
  class r extends a {
5576
5597
  static get name() {
@@ -5583,7 +5604,7 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
5583
5604
  return !0;
5584
5605
  }
5585
5606
  get interactive() {
5586
- return (this.arguments || []).some((e) => e === "--help" || e === "-h" || e === "--version" || e === "-V" || e === "-v") ? !1 : this._isInteractive === void 0 ? !!(n.interactive || e === "nano") : !!this._isInteractive;
5607
+ return (this.arguments || []).some((e) => e === "--help" || e === "-h" || e === "--version" || e === "-V" || e === "-v") ? !1 : this._isInteractive === void 0 ? !!(n.interactive || e === "nano" || e === "pico" || e === "vim" || e === "vi") : !!this._isInteractive;
5587
5608
  }
5588
5609
  get captureInput() {
5589
5610
  return this.interactive;
@@ -5721,11 +5742,22 @@ var A, j, M, N, P, F, I, L, ee, R, z = e((() => {
5721
5742
  }
5722
5743
  _generateJsCommandSource(e, t) {
5723
5744
  if (e.adapter === "wllama" || e.name === "wllama") {
5724
- let n = r.resolve(__dirname, "packages/wllama.js");
5725
- return `'use strict';
5726
- let wllamaModule;
5727
- try {
5728
- wllamaModule = require(${JSON.stringify(n)});\n} catch (_) {\n try {\n wllamaModule = require('brsh/wbt/packages/wllama');\n } catch (e) {\n wllamaModule = require('./wllama');\n }\n}\nmodule.exports = wllamaModule.createWllamaCommand(${JSON.stringify(e)}, {}, ${JSON.stringify(t)});\n`;
5745
+ let n = typeof __dirname < "u" ? r.resolve(__dirname, "packages/wllama.js") : null;
5746
+ return "'use strict';\nlet wllamaModule;\nif (typeof require === 'function') {\n" + (n ? ` try {\n wllamaModule = require(${JSON.stringify(n)});\n } catch (_) {}\n` : "") + ` if (!wllamaModule) {
5747
+ try {
5748
+ wllamaModule = require('brsh/wbt/packages/wllama');
5749
+ } catch (_) {
5750
+ try { wllamaModule = require('./wllama'); } catch (e) {}
5751
+ }
5752
+ }
5753
+ }
5754
+ if (!wllamaModule && typeof globalThis !== 'undefined') {
5755
+ wllamaModule = globalThis.__brshWllamaAdapter;
5756
+ }
5757
+ if (!wllamaModule) {
5758
+ throw new Error('Unable to load wllama adapter module');
5759
+ }
5760
+ module.exports = wllamaModule.createWllamaCommand(${JSON.stringify(e)}, {}, ${JSON.stringify(t)});\n`;
5729
5761
  }
5730
5762
  let n = JSON.stringify(e, null, 2);
5731
5763
  return e.repl ? `'use strict';\nconst pkgMeta = ${n};\nconst _Repl = typeof ReplCommand !== 'undefined' ? ReplCommand : (typeof require !== 'undefined' ? require('brsh/ReplCommand') : globalThis.ReplCommand);\nmodule.exports = _Repl.createReplWasmCommand(pkgMeta, {}, ${JSON.stringify(t)});\n` : `'use strict';\nconst pkgMeta = ${n};\nconst _Wasm = typeof WasmCommand !== 'undefined' ? WasmCommand : (typeof require !== 'undefined' ? require('brsh/WasmCommand') : globalThis.WasmCommand);\nmodule.exports = _Wasm.createGenericWasmCommand(pkgMeta, {}, ${JSON.stringify(t)});\n`;