mirror of
https://github.com/hanzoai/bot.git
synced 2026-10-30 17:24:26 +00:00
Refactor following review:
• Dropped Postgres backend entirely. Don't ship complexity solo devs
don't need. SQLite is the one canonical default — single file at
~/.hanzo-bot/brain/brain.db, zero infra, single static binary.
• Kept the BrainStore interface pluggable. New `registerBackend(name,
factory)` API lets 3rd parties ship Postgres / LanceDB / D1 / libSQL
as sibling extensions without forking core memory. Env override
HANZO_BRAIN_BACKEND=<name> selects at runtime.
• Renamed package @hanzo/bot-memory-postgres → @hanzo/bot-memory.
Single source of truth for the BrainStore contract; SQLite is the
one backend that ships with the bot.
• README per extension:
brain/README.md — meta-pack overview + gbrain comparison
memory/README.md — schema spec + pluggability + driver
graph-links/README.md — edge-type table + zero-LLM rationale
recipes-brain/README.md — swipe-train loop + recipe authoring
• Pluggability tests added — registerBackend exposes new backends,
unknown backend throws a helpful error.
Tests: 18/18 brain extensions pass (was 16, +2 for pluggability).
End-to-end smoke confirms: SQLite default, listBackends()=["sqlite"],
edges + facts + FTS hybrid search + recipe load all green.
The Postgres path can come back as @hanzo/bot-memory-postgres in a
separate package later. Schema is fully spec'd in memory/sqlite.ts so
re-implementation is mechanical.
33 lines
1.1 KiB
TypeScript
33 lines
1.1 KiB
TypeScript
/**
|
|
* @hanzo/bot-brain — meta-pack
|
|
*
|
|
* Bundles the three brain pieces into a single drop-in plugin:
|
|
* • memory (pluggable BrainStore — SQLite default, single file)
|
|
* • graph-links (zero-LLM typed-link extractor)
|
|
* • recipes-brain (canonical ingest recipes: email, calendar, …)
|
|
*
|
|
* Wires them so a page write → edge extraction → fact recall → hybrid
|
|
* search all flow through one store. Result: gbrain-equivalent on top
|
|
* of Hanzo Bot, single config object, zero extra infra.
|
|
*/
|
|
|
|
import registerGraph from "@hanzo/bot-graph-links";
|
|
import registerMemory, { type MemoryApi, type MemoryConfig } from "@hanzo/bot-memory";
|
|
|
|
export interface BrainConfig {
|
|
memory?: MemoryConfig; // backend, dataDir, dbPath, embedding
|
|
graph?: { enabled?: boolean };
|
|
recipes?: string[]; // names to enable (email, calendar, …)
|
|
}
|
|
|
|
export default async function register(
|
|
api: any,
|
|
cfg: BrainConfig = {},
|
|
): Promise<{ memory: MemoryApi }> {
|
|
const memory = await registerMemory(api, cfg.memory ?? {});
|
|
if (cfg.graph?.enabled !== false) {
|
|
registerGraph(api);
|
|
}
|
|
return { memory };
|
|
}
|