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 +14 -0
- package/dist/wbt.es.js +65 -33
- package/dist/wbt.es.js.map +1 -1
- package/dist/wbt.min.js +19 -5
- package/dist/wbt.min.js.map +1 -1
- package/lib/wbt/index.js +21 -9
- package/lib/wbt/packages/wllama.js +13 -14
- package/lib/wbt/registry.js +18 -1
- package/package.json +1 -1
- package/test/wbt.test.js +99 -4
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
|
-
|
|
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 = ""
|
|
5320
|
-
for await (let
|
|
5321
|
-
let e =
|
|
5322
|
-
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
|
|
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
|
|
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 && (
|
|
5337
|
-
let
|
|
5338
|
-
if (
|
|
5339
|
-
let e = ""
|
|
5340
|
-
for await (let
|
|
5341
|
-
let
|
|
5342
|
-
|
|
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
|
|
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(
|
|
5347
|
-
let
|
|
5348
|
-
return typeof t == "function" &&
|
|
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
|
|
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
|
|
5512
|
-
|
|
5513
|
-
|
|
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(),
|
|
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()
|
|
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
|
|
5726
|
-
|
|
5727
|
-
|
|
5728
|
-
|
|
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`;
|