brainy/src
David Snelling 5d9ec5bb16 fix: resolve WASM loading for Bun --compile single-binary executables
Both roaring-wasm and candle-wasm now work correctly in all environments:
- Node.js (fs.readFileSync)
- Bun runtime (Bun.file)
- Bun --compile (embedded assets via import { type: 'file' })
- Browser (fetch)

roaring-wasm:
- Created src/utils/roaring/index.ts wrapper
- Uses browser bundle which has WASM embedded as base64
- Top-level await ensures initialization before use
- Zero environment detection needed (works everywhere)

candle-wasm:
- Created src/embeddings/wasm/wasmLoader.ts universal loader
- Uses Bun's import { type: 'file' } to embed 93MB WASM in compiled binary
- Fixed browser detection (Bun defines 'self', check for 'document' instead)
- Simplified CandleEmbeddingEngine.ts to use wasmLoader

Binary size verification:
- Minimal Bun binary: 100MB (runtime only)
- Brainy binary: 199MB (100MB runtime + 93MB WASM + 6MB JS)
- No duplication: WASM embedded exactly once

Test results:
- Node.js: 1190/1190 tests pass
- Bun runtime: 8/8 tests pass
- Bun --compile: 8/8 tests pass

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-06 14:09:02 -08:00
..
api feat: ID-first storage architecture + remove memory-unsafe APIs (v6.0.0) 2025-11-19 16:46:11 -08:00
augmentations fix(versioning): clean architecture with index pollution prevention 2025-12-09 09:36:10 -08:00
cli feat: ID-first storage architecture + remove memory-unsafe APIs (v6.0.0) 2025-11-19 16:46:11 -08:00
config fix: remove dead model config code for true zero-config 2025-12-18 10:31:02 -08:00
cortex feat: Stage 3 CANONICAL taxonomy with 169 types (v5.5.0) 2025-11-06 09:02:23 -08:00
critical feat: replace transformers.js with direct ONNX WASM for Bun compatibility 2025-12-17 17:42:37 -08:00
data feat: Phase 3 - Unified Semantic Type Inference (Nouns + Verbs) 2025-10-16 10:59:26 -07:00
distributed feat(v4.0.0): Complete metadata/vector separation architecture with Azure support 2025-10-17 12:29:27 -07:00
embeddings fix: resolve WASM loading for Bun --compile single-binary executables 2026-01-06 14:09:02 -08:00
errors feat: Brainy 3.0 - Production-ready Triple Intelligence database 2025-09-11 16:23:32 -07:00
graph fix(architecture): singleton GraphAdjacencyIndex via storage.getGraphIndex() (v6.3.0) 2025-12-04 12:55:23 -08:00
hnsw perf(hnsw): deferred persistence mode for 30-50× faster cloud storage adds 2025-12-02 14:20:04 -08:00
import fix: resolve v5.7.3 race condition by persisting write-through cache (v5.7.4) 2025-11-12 13:18:53 -08:00
importers fix: update all Stage 2 references to Stage 3 CANONICAL type counts 2025-11-06 09:40:33 -08:00
interfaces feat: implement always-adaptive caching with getCacheStats monitoring 2025-10-10 14:09:30 -07:00
mcp refactor: streamline core API surface 2025-10-04 08:52:06 -07:00
neural feat: migrate embeddings to Candle WASM + remove semantic type inference 2026-01-06 12:52:34 -08:00
patterns 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00
scripts feat: add node: protocol to all Node.js built-in imports for bundler compatibility 2025-09-17 14:20:21 -07:00
shared refactor: remove deprecated BrainyData class completely 2025-09-30 16:04:00 -07:00
storage fix(architecture): singleton GraphAdjacencyIndex via storage.getGraphIndex() (v6.3.0) 2025-12-04 12:55:23 -08:00
streaming feat: Brainy 3.0 - Production-ready Triple Intelligence database 2025-09-11 16:23:32 -07:00
transaction feat: add v5.8.0 features - transactions, pagination, and comprehensive docs 2025-11-14 10:26:23 -08:00
triple feat: migrate embeddings to Candle WASM + remove semantic type inference 2026-01-06 12:52:34 -08:00
types fix: remove dead model config code for true zero-config 2025-12-18 10:31:02 -08:00
universal fix: prevent fs adapter from throwing on import in browser 2025-09-17 16:22:02 -07:00
utils fix: resolve WASM loading for Bun --compile single-binary executables 2026-01-06 14:09:02 -08:00
versioning fix(versioning): VFS file versions now capture actual blob content 2025-12-09 16:13:45 -08:00
vfs fix(vfs): prevent race condition in bulkWrite by ordering operations 2025-12-11 13:26:07 -08:00
augmentationManager.ts feat: Brainy 3.0 - Production-ready Triple Intelligence database 2025-09-11 16:23:32 -07:00
augmentationPipeline.ts feat: Brainy 3.0 - Production-ready Triple Intelligence database 2025-09-11 16:23:32 -07:00
brainy.ts feat: migrate embeddings to Candle WASM + remove semantic type inference 2026-01-06 12:52:34 -08:00
coreTypes.ts perf: eliminate N+1 patterns across all APIs for 10-20x faster cloud storage 2025-11-20 15:18:26 -08:00
cortex.ts 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00
index.ts feat: migrate embeddings to Candle WASM + remove semantic type inference 2026-01-06 12:52:34 -08:00
pipeline.ts 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00
setup.ts feat: migrate embeddings to Candle WASM + remove semantic type inference 2026-01-06 12:52:34 -08:00
unified.ts chore: enforce consistent coding style and semicolon removal 2025-09-29 09:50:59 -07:00
worker.ts 🧠 Brainy 2.0.0 - Zero-Configuration AI Database with Triple Intelligence™ 2025-08-26 12:32:21 -07:00