For developers embedding the Brain in their own code or agent.
Updated
The BrainBox SDK (@brainbox-labs/sdk, 0.26.1) gives TypeScript code one handle with ingest, recall and update verbs that map to the hosted MCP tools, a sync for folders of docs, project listing, and a builder for a local MCP server. Recall and update can be passed straight to an agent framework as tools.
Everything starts from a BrainBox handle. apiUrl defaults to the hosted service.
import { BrainBox } from '@brainbox-labs/sdk';
const brain = new BrainBox({
apiKey: process.env.BRAINBOX_API_KEY!,
org: 'my-org',
project: 'my-project',
});brain.ingest blocks until each stage is published. recall_wiki hits carry the matching passage. create_learning files a correction.
await brain.ingest({
postgres: { connectionString: process.env.DATABASE_URL! },
docs: ['./docs/**/*.md'],
});
const hits = await brain.recall.recall_wiki({ q: 'returns policy' });
await brain.update.create_learning({
rule: 'Returns over 30 days are written off, not refunded.',
});asTools() returns tool objects you can pass to an agent framework, each with an input schema and an execute method.
const tools = [...brain.recall.asTools(), ...brain.update.asTools()];For a script that does not need a TypeScript handle, brainbox tool runs the same verbs with your brainbox login, so there is no key to create or store. See the CLI reference.
npx -y @brainbox-labs/cli@latest tool recall_wiki --project support-brain --args '{"q":"refund policy"}'brain.sync keeps a folder in step with the Brain by stable key: it uploads only new and changed docs and reports docs deleted locally as pendingDeletes. Nothing is archived unless you apply it with brain.prune. Preview first with dryRun.
const plan = await brain.sync({ dir: './docs/kb', dryRun: true });
const result = await brain.sync({ dir: './docs/kb' });
if (result.pendingDeletes.length) {
await brain.prune(result.pendingDeletes.map((d) => d.sourceKey));
}| Namespace | Use |
|---|---|
| brain.ingest | Ingest a database schema, SQL files, docs and text; blocks until published |
| brain.recall | Read the Brain: get_index, recall_domain, recall_wiki, recall_traces, get_wiki_page, list_learnings and more |
| brain.update | Write: create_learning, process_event, create_skill, save_wiki_page, report_context_gap and more |
| brain.sync, brain.prune | Keep a folder of docs in step by stable key; archive reviewed deletes |
| brain.projects | List the organization's projects and create one |
| brain.serve | Build and start a local MCP server for your approved tools |