Getting started
Install
npm i @db0-ai/core @db0-ai/backends-sqlite
The core package provides the harness API. The SQLite backend stores everything locally — no network, no signup.
Create a harness
import { db0 } from "@db0-ai/core"
import { createSqliteBackend } from "@db0-ai/backends-sqlite"
const backend = await createSqliteBackend({ dbPath: "./agent.db" })
const harness = db0.harness({
agentId: "my-agent",
sessionId: "session-1",
userId: "user-123",
backend,
})
Every operation goes through the harness. It scopes memory, state, and logs to this specific agent + session + user combination.
Write and search memories
// write a memory
await harness.memory().write({
content: "User prefers dark mode and TypeScript",
scope: "user",
embedding, // number[] from your embedding provider
tags: ["preference"],
})
// search memories
const results = await harness.memory().search({
embedding: queryVec,
scope: ["user", "agent"],
scoring: "hybrid",
limit: 10,
})
for (const r of results) {
console.log(r.content, r.score)
}
Checkpoint state
// save a checkpoint before a risky operation
const cp = await harness.state().checkpoint({
label: "before-api-call",
})
// ... do something risky ...
// roll back if it went wrong
await harness.state().restore(cp.id)
Log events
await harness.log().append({
event: "tool_call",
level: "info",
data: { tool: "web_search", query: "TypeScript best practices" },
})
Close
await harness.close()
Only the root harness closes the backend. Spawned sub-agents share the connection.