Open source · MIT · v0.0.1

An AI that is
born insideyour app

Bela ships with zero domain knowledge. It reads your config, reads your live data, and trains its own model from scratch — in about a second, on one CPU core. No pretrained brain, no API key, nothing to leak. It reads a command, does the thing, and tells you it's done.

MIT · TypeScript · one runtime dependency · $4/mo CPU VPS

Bela's architecture drawn as an insect nervous system A vertical nerve cord carrying four ganglia — template match, self-trained network, resolve and gate and run, and an optional LLM socket marked as roadmap — with lateral circuit traces ending in contact pads. TEMPLATE MATCH SELF-TRAINED NET RESOLVE · GATE · RUN LLM SOCKET — ROADMAP
Reflexes are local and guaranteed. The head is optional.
0.068 msavg command
0.5 sfull self-train
8 MBtrained model
99.5%intent accuracy, live
$4/moCPU-only hosting

Measured on a single CPU core with no GPU by the repository's own benchmark scripts — p99 0.21 ms over 2,000 commands. 113/113 tests passing across 23 files.

AnatomyThree layers, one nerve cord

Shaped like an insect, not a brain

A brain is one large thing that must always be present. An insect's nervous system is a chain of small ganglia that keep working when you take the head off. Bela is built the second way — on purpose.

Deterministic reflexes handle the overwhelming majority of real commands. The self-trained network catches the paraphrases nobody wrote down. Behind both sits a socket, not a dependency: the interface the neural fallback plugs into is the same one an LLM adapter will plug into. Cut the head off and the insect keeps walking.

Reflex Utterance templates, fuzzy entity resolution against your synced data, and dedicated extractors for dates, numbers and identifiers. Fast, auditable, and it either matches or it honestly does not. 0.068 ms
Instinct The neural fallback you trained yourself, engaged only when no template matches at all — “get karahi in room 4” against templates that only ever said “order”. ~1.4 ms
Socket Planned: an LLM adapter on that same interface, and Bela exposed as an MCP server so a large agent stack acts through these gates. Optional in both directions. roadmap

The knowledge base is a periodic pull: every entity you declare has a resolve() that returns its current rows — a Prisma query, a SQL call, an API fetch, your code. A sync failure keeps the last good snapshot rather than degrading the agent.

agent.tools.ts — the entire developer contract
export default defineAgent({
  entities: {
    Room:     { resolve: () => prisma.room.findMany(),     match: ["number"] },
    MenuItem: { resolve: () => prisma.menuItem.findMany(), match: ["name", "aliases"] },
  },
  tools: [
    tool("orderFood", {
      params:     { qty: number({ default: 1 }), item: entity("MenuItem"), room: entity("Room") },
      utterances: ["order {qty} {item} for room {room}", "{item} for room {room}"],
      run:        ({ item, room, qty }) => api.post("/api/orders", { itemId: item.id, roomId: room.id, qty }),
    }),
    tool("cancelBooking", {
      params:     { guest: entity("Guest") },
      utterances: ["cancel {guest} booking"],
      confirm:    true,          // never runs on a fresh match
      roles:      ["manager"],   // anyone else gets `denied`
      run:        ({ guest }) => bookings.cancel(guest.id),
    }),
  ],
})
Duplicate tool names, references to undeclared entities, and placeholders with no matching param all throw at build time rather than at runtime in front of a user. Then bela train prints intentAcc / slotExact / testCount and refuses to save the artifact if it misses the quality gate. A config change that quietly wrecks model quality cannot ship.

SafetyStructural, not prompted

It cannot guess, because it was never given the option

Bela cannot touch your database and cannot write SQL. The only things it can do are call functions you explicitly registered, with arguments it has resolved to real rows in your data. Your business rules stay in your app, where you can test them. Four gates sit between a parsed command and a mutation.

Never guess on writes

Low confidence, an unresolved required slot, or an entity that matched two rows — two guests named John — produces a question, not a best guess. The per-user session remembers what was already filled in, so the reply is one short answer rather than the whole command again.

Enforced confirmation

A tool marked confirm: true never executes on a fresh match. It echoes the resolved arguments and waits for an explicit yes or no from the same user — in English or Roman-Urdu (haan, ji / nahi). There is no code path that skips this.

Role gates

A tool with a roles list checks the caller's role, supplied by your app per request, and returns a denied outcome instead of running. The tool never executes and nothing is mutated.

Audit trail

An optional callback fires on every executed, errored, denied and cancelled outcome with the user, raw input, tool, resolved arguments and timestamp. If your audit callback throws, the pipeline swallows it — a broken logger cannot break command handling.

Around those: tool handler exceptions are caught and templated into a safe user-facing message, so your error text never leaks; sessions expire on a TTL so stale follow-ups die quietly; a retrain that fails leaves the previous artifact serving; and a corrupted or hand-edited model file fails fast at load with a clear error instead of crashing deep inside prediction. Unmatched input returns an unknown outcome whose reply lists what the agent can do. Never a guess, never chit-chat.

In the wildLive today

It is already running a hotel

Bela's first production integration is live. It runs inside a deployed hotel & restaurant management system, trained on that property's real data — 99.5% held-out intent accuracy, about one second of training on the box itself — with 26 tools calling the application's own permission-checked server actions.

Staff type the shorthand they actually use, including Roman-Urdu phrasings; Urdu digits normalise to ASCII on their own. Dialogue and confirmations were verified live, and results reach staff over WhatsApp, verified end to end. The integration itself is one config file and one API route.

Mis-parsed phrasings are captured through the correction store and folded into the next retrain, so the model converges on how these staff talk instead of you hand-editing templates forever. Corrections pass the same accuracy gate, so a bad correction cannot degrade the live model.

Bela is v0.0.1 and honest about it. The deterministic engine, the self-trained fallback, the dialogue safety layer and the CLI all work and are covered by 113 passing tests including end-to-end fixtures. On npm today: npm install bela-ai.

Honest comparisonIncluding where it loses

Bela is not a better LLM. It is a different shape of tool.

It loses badly outside its shape, and the bold rows are exactly where. Read them before you choose.

 BelaCloud-LLM agent
Marginal cost per commandZeroPer token
Infrastructure$4–12/mo CPU VPSAPI account, or a GPU
Works offlineYesNo
Data leaves your serverNeverEvery request
LatencySub-millisecond300 ms – several seconds
Determinism / auditabilityFullPartial
Behaviour changes under youNever — the artifact is yoursOn provider model updates
Open-ended conversationNoYes
Reasoning over novel situationsNoYes
Multi-step planningNoYes
Phrasings nobody anticipatedOnly via retrain on correctionsOften, zero-shot
Setup effortWrite a config, train, wire it inWrite prompts and tool schemas

If your users need to converse, reason about things outside the app, or chain several unplanned steps — use an LLM. Bela will not get there. If your users need to fire a known action fast, safely, cheaply and offline, Bela is the smaller and stronger tool. The roadmap's LLM adapter exists precisely so you do not have to choose forever.

RoadmapDesigned, not yet built

Big ambitions, still small

Everything below is planned work, stated as such. None of it changes the rule that a trained command keeps working with the network unplugged.

Memory

A brain file you own

bela-memory.md — readable, editable, portable to a fresh install. Entries are structured facts, not instructions: an alias becomes a resolver synonym, a phrasing becomes a training correction. No model interprets it, so prompt-injection-shaped risks largely do not apply.

Call up

The head is optional

On low-confidence input, optionally consult an LLM over any OpenAI-compatible endpoint. It may only suggest a tool call — the suggestion still passes the resolver, role gate, confirmation and audit trail. If it is unreachable, every trained command still works.

Called down

MCP server

Expose Bela over MCP so big-LLM agent stacks invoke your app's actions through Bela's safety gates — Bela as the hands layer for any agent. This also unlocks distilling exactly what your project needs, once, into a local model.

Linking

Agent to agent

The core is transport-agnostic, so another Bela is just an authenticated caller with a role — roles, confirmations and audit apply to a foreign agent for free. Needs shared-key auth, loop prevention, and provenance in the audit entries.

Sidecar

Beyond Node

PHP/WordPress, Laravel and Django: Bela runs as its own small process, tools are declared as REST endpoints in a JSON or YAML config, and entity resolvers become read-only HTTP endpoints. Same engine, HTTP transport — no redesign, just not built yet.

Small enough to own. Useful enough to trust.

The smallest useful AI model people can run to operate their own application — nothing more, nothing less.