brsh 3.4.0 → 3.6.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 +14 -0
- package/dist/shell.es.js +303 -151
- package/dist/shell.es.js.map +1 -1
- package/dist/shell.min.js +18 -18
- package/dist/shell.min.js.map +1 -1
- package/dist/wbt.es.js +589 -306
- package/dist/wbt.es.js.map +1 -1
- package/dist/wbt.min.js +10 -10
- package/dist/wbt.min.js.map +1 -1
- package/lib/WasmCommand.js +301 -10
- package/lib/wbt/index.js +11 -0
- package/lib/wbt/packages/wllama.js +399 -120
- package/lib/wbt/registry.js +2 -1
- package/package.json +1 -1
- package/test/fixtures/nano.wasm +0 -0
- package/test/wbt.test.js +48 -2
package/lib/wbt/registry.js
CHANGED
|
@@ -178,7 +178,8 @@ const DEFAULT_REGISTRY = {
|
|
|
178
178
|
cdnUrl: 'https://cdn.jsdelivr.net/gh/eliotstocker/nano-wasm@main/dist/nano.wasm',
|
|
179
179
|
wasmUrl: 'https://cdn.jsdelivr.net/gh/eliotstocker/nano-wasm@main/dist/nano.wasm',
|
|
180
180
|
type: 'custom-wasm',
|
|
181
|
-
|
|
181
|
+
interactive: true,
|
|
182
|
+
size: '680 KB'
|
|
182
183
|
}
|
|
183
184
|
};
|
|
184
185
|
|
package/package.json
CHANGED
|
Binary file
|
package/test/wbt.test.js
CHANGED
|
@@ -8,9 +8,13 @@ const fs = require('fs');
|
|
|
8
8
|
const Wbt = require('../lib/wbt/index.js');
|
|
9
9
|
const { wllamaInstances, DEFAULT_MODEL_URL, MODEL_ALIASES, resolveModelSpec } = require('../lib/wbt/packages/wllama.js');
|
|
10
10
|
|
|
11
|
+
const FIXTURE_NANO_WASM = path.resolve(import.meta.dirname, 'fixtures/nano.wasm');
|
|
11
12
|
const NANO_WASM_PATH = path.resolve(import.meta.dirname, '../../nano-wasm/dist/nano.wasm');
|
|
12
13
|
const NANO_WASM_BYTES = (() => {
|
|
13
14
|
try {
|
|
15
|
+
if (fs.existsSync(FIXTURE_NANO_WASM)) {
|
|
16
|
+
return new Uint8Array(fs.readFileSync(FIXTURE_NANO_WASM));
|
|
17
|
+
}
|
|
14
18
|
if (fs.existsSync(NANO_WASM_PATH)) {
|
|
15
19
|
return new Uint8Array(fs.readFileSync(NANO_WASM_PATH));
|
|
16
20
|
}
|
|
@@ -1176,7 +1180,8 @@ describe('WBT Wllama v3 WASM & WebGPU package (`wllama`, `llama`, `llama-cli`)',
|
|
|
1176
1180
|
expect(noStreamRes.output.join('\n')).toContain('Reply(WebGPU,turns=1): No stream');
|
|
1177
1181
|
expect(noStreamTokens.length).toBe(0);
|
|
1178
1182
|
|
|
1179
|
-
// Test status indication (loading model, running inference)
|
|
1183
|
+
// Test status indication (loading model weights, running inference)
|
|
1184
|
+
wllamaInstances.clear();
|
|
1180
1185
|
const statusUpdates = [];
|
|
1181
1186
|
const onStatus = (chunk) => statusUpdates.push(chunk);
|
|
1182
1187
|
shell.stderr.on('data', onStatus);
|
|
@@ -1188,8 +1193,9 @@ describe('WBT Wllama v3 WASM & WebGPU package (`wllama`, `llama`, `llama-cli`)',
|
|
|
1188
1193
|
|
|
1189
1194
|
shell.stderr.removeListener('data', onStatus);
|
|
1190
1195
|
const combinedStatus = statusUpdates.join('');
|
|
1191
|
-
expect(combinedStatus).
|
|
1196
|
+
expect(combinedStatus).toContain('Loading model (tinyllama.gguf) weights');
|
|
1192
1197
|
expect(combinedStatus).toContain('Running inference');
|
|
1198
|
+
expect(combinedStatus).toMatch(/\[.*\]/);
|
|
1193
1199
|
});
|
|
1194
1200
|
|
|
1195
1201
|
it('supports Hugging Face model loading (--hf / hf:), embeddings (wllama embed), info, and bench', async () => {
|
|
@@ -1413,6 +1419,46 @@ describe('WBT GNU nano WASM package (nano / nano-wasm)', () => {
|
|
|
1413
1419
|
expect(res.getExitCode()).toBe(0);
|
|
1414
1420
|
expect(res.getStdOutput().map(l => l.string).join('\n')).toMatch(/GNU nano, version 8\.0|nano.*8\.0\.0.*wasm/i);
|
|
1415
1421
|
});
|
|
1422
|
+
|
|
1423
|
+
it('runs nano interactively, accepts text input, writes out file, and exits cleanly', async () => {
|
|
1424
|
+
if (!NANO_WASM_BYTES) return;
|
|
1425
|
+
await run(shell, 'wbt install nano');
|
|
1426
|
+
|
|
1427
|
+
const stdoutChunks = [];
|
|
1428
|
+
const onData = (chunk) => stdoutChunks.push(chunk);
|
|
1429
|
+
shell.stdout.on('data', onData);
|
|
1430
|
+
|
|
1431
|
+
const cmdPromise = shell.onCommand('nano /test.txt');
|
|
1432
|
+
|
|
1433
|
+
// Allow nano to initialize, query terminal size, enter alt-screen, and render initial UI
|
|
1434
|
+
await new Promise(r => setTimeout(r, 60));
|
|
1435
|
+
|
|
1436
|
+
// Type text into nano
|
|
1437
|
+
for (const ch of 'Hello from nano!') {
|
|
1438
|
+
shell.onInput(ch);
|
|
1439
|
+
}
|
|
1440
|
+
await new Promise(r => setTimeout(r, 30));
|
|
1441
|
+
|
|
1442
|
+
// Save file: Ctrl+O, then Enter to confirm filename
|
|
1443
|
+
shell.onInput('^O');
|
|
1444
|
+
await new Promise(r => setTimeout(r, 30));
|
|
1445
|
+
shell.onInput('Enter');
|
|
1446
|
+
await new Promise(r => setTimeout(r, 30));
|
|
1447
|
+
|
|
1448
|
+
// Exit nano: Ctrl+X
|
|
1449
|
+
shell.onInput('^X');
|
|
1450
|
+
|
|
1451
|
+
await cmdPromise;
|
|
1452
|
+
shell.stdout.off('data', onData);
|
|
1453
|
+
|
|
1454
|
+
const saved = shell.context.fs.getFileByPath('/test.txt');
|
|
1455
|
+
const joinedOutput = stdoutChunks.join('');
|
|
1456
|
+
|
|
1457
|
+
expect(shell.lastCode).toBe(0);
|
|
1458
|
+
expect(saved).toContain('Hello from nano!');
|
|
1459
|
+
expect(joinedOutput).toContain('\x1b[?1049h'); // entered alt screen
|
|
1460
|
+
expect(joinedOutput).toContain('\x1b[?1049l'); // exited alt screen
|
|
1461
|
+
});
|
|
1416
1462
|
});
|
|
1417
1463
|
|
|
1418
1464
|
|