← Back to PRs

#6051: feat(memory): add Bun sqlite compatibility

by cheeeee open 2026-02-01 07:01 View on GitHub →
## Summary Add runtime detection and compatibility wrapper for Bun's `bun:sqlite` to work with the existing `node:sqlite` API used in memory search. ## Changes - Detect Bun runtime via `globalThis.Bun` - Wrap `bun:sqlite` Database class to match `node:sqlite` DatabaseSync API - Handle extension loading differences between runtimes ## Why When running the gateway under Bun, memory search fails with: ``` No such built-in module: node:sqlite ``` Bun has its own `bun:sqlite` with a slightly different API. This patch provides a compatibility layer so memory search works on both Node.js and Bun. ## Testing - Tested on Bun 1.3.5 - Memory search with custom embeddings endpoint works - Extension loading (sqlite-vec) compatibility preserved <!-- greptile_comment --> <h2>Greptile Overview</h2> <h3>Greptile Summary</h3> Adds runtime detection for Bun (`globalThis.Bun`) and a compatibility shim that returns a `node:sqlite`-shaped module under Bun by wrapping `bun:sqlite`’s `Database` into a `DatabaseSync`-like class, plus a small stubbed export surface (`StatementSync`, `constants`, `backup`). This allows the memory module (e.g. `src/memory/manager.ts` opening the DB and `src/memory/sqlite-vec.ts` loading extensions) to run when `node:sqlite` is unavailable under Bun. <h3>Confidence Score: 3/5</h3> - Mostly safe, but the Bun wrapper still has some behavior mismatches that can change runtime semantics in edge cases. - Change is isolated to the sqlite loader and is straightforward, but the Bun compatibility layer is intentionally type-erased and may diverge from `node:sqlite` semantics; one concrete mismatch is in-memory database path handling. Previous review threads also indicate potential Statement API/constant-value mismatches that could surface at runtime under Bun. - src/memory/sqlite.ts <!-- greptile_other_comments_section --> <!-- /greptile_comment -->

Most Similar PRs