Documentation

Docs · v0.0.1 · MIT

Documentation

Bela is an app-scoped, self-training agent engine. You declare your entities and tools in one config file, it trains its own intent classifier and slot tagger from scratch — in about a second on one CPU core — and then executes short commands against the functions you registered. Everything below is generated from the markdown docs in the repository, which stay the source of truth.

Quickstart

Three steps: scaffold a config, fill in your real entities and tools, train. The CLI is the recommended path — it wraps trainModel/saveModel with an accuracy gate, so a config change that tanks model quality can't silently ship a bad artifact.

terminal — from zero to a trained model
# 1. scaffold a starter agent.tools.mjs
bela init ./my-agent

# 2. write your real entities and tools
$EDITOR ./my-agent/agent.tools.mjs

# 3. train — saves only if it clears the quality gate
bela train --config ./my-agent/agent.tools.mjs --out ./my-agent/bela-model.json
intentAcc=0.9891 slotExact=1.0000 testCount=92
saved model to ./my-agent/bela-model.json

# optional: re-check a saved artifact any time
bela eval --config ./my-agent/agent.tools.mjs --model ./my-agent/bela-model.json
The unedited starter config (two entities, two tools) already clears the default gate — intentAcc>=0.9, slotExact>=0.8 — out of the box. Note: @bela/cli isn't on npm yet, so there is no npx bela … today; inside the monorepo the same init/train/eval functions run under npx tsx. See the CLI reference.

Then wire the agent into your app — one config, one call per message:

app.ts — load the model, handle a command
import { defineAgent, createAgent } from "@bela/core"
import { loadModel, makeFallback } from "@bela/model"

const config = defineAgent({ entities, tools })
const model  = loadModel("./bela-model.json")
const agent  = createAgent(config, { fallback: makeFallback(model, 0.6) })

await agent.sync()                      // pull fresh entity rows
const outcome = await agent.handle(text, { userId: "u1", role: "manager" })
// branch on outcome.type: executed | need_slot | ambiguous | confirm
//                          cancelled | denied | unknown | error
Full walkthrough — entities, tools, outcomes, sessions, roles, audit, corrections — in the integration guide.

The guides

What Bela is (and isn't)

Bela is not a chatbot and not a better LLM — it is an action executor of a different shape. It reads one short command, resolves it against your app's real data, calls a function you registered, and replies with one short line. It does no open-ended conversation and knows nothing outside your application.

 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
Open-ended conversationNoYes
Reasoning over novel situationsNoYes
Multi-step planningNoYes

If your users need to converse, reason about things outside the app, or chain several unplanned steps — use an LLM. If they need to fire a known action fast, safely, cheaply and offline, Bela is the smaller and stronger tool. The full row-by-row comparison lives in the whitepaper.