← Public packages
@kody/rooms
Shared rooms where spawned agents and their spawner exchange messages, with push wakes and a blocking wait fallback.
Files
import { DatabaseSync } from 'node:sqlite'
import type { Db } from './db.ts'
/** In-memory SQLite with the same `sql()` shape as Kody package storage. Tests only. */
export function memoryDb(): Db {
const db = new DatabaseSync(':memory:')
return {
async sql(query, params = []) {
const statement = db.prepare(query)
const values = params.map((value) => (typeof value === 'boolean' ? Number(value) : value)) as Array<null | number | string>
if (/^\s*(SELECT|WITH)|RETURNING/i.test(query)) return { rows: statement.all(...values) as Array<Record<string, unknown>> }
statement.run(...values)
return { rows: [] }
},
}
}