Build on Bevia

The SDK

A thin client over the public doors, and nothing else. TypeScript first; a Python reference client; any language through the protocol.

What it is — and is not

@bevia/sdk is MIT, public, zero dependencies, so anyone can read every line of what it sends. It wraps every door of the protocol as a cognitive operation and adds no door the protocol does not have.

  • No engine code — the engine is not in the package.
  • No database driver — it cannot open the substrate, and no door returns a database handle.
  • No owner-only route — revoking sensors, resolving proposals, clearing or importing a World, materializing the vault are the owner's, through the app, and are not in the package.
  • No owner key — the model the owner configured is invoked by the engine on ask; your program never sees the owner's key.

npm run audit:surface proves it mechanically before every publish: the tarball holds only dist/, README.md and LICENSE; the built code references no engine module and speaks only the doors the protocol publishes. If you can do something with the SDK that the protocol document does not describe, that is a bug.

TypeScript / JavaScript

Node 18+, Deno, Bun and browsers. Server-sent events ride fetch, so the same code streams everywhere and carries the bearer header EventSource cannot.

import { connectLocal, BeviaClient, BeviaError } from "@bevia/sdk";

const bevia = await connectLocal();                                     // workspace file, or BEVIA_ENGINE_URL + BEVIA_TOKEN
const other = new BeviaClient({ url: "http://127.0.0.1:PORT", token }); // a token you paired yourself

try {
  await bevia.exportSubstrate();
} catch (err) {
  if (err instanceof BeviaError) console.log(err.status, err.capability);   // 401 "substrate_export" — ask the owner
}

The surface

OperationDoor · capability
intake.validate · intake.submit/intake/validate · /intake/capture · capture
world.inspect(id) · history · document · at(manifest)one understanding and the published documents · read
world.current · snapshot · publication · diff · inspect()the whole World · control (owner only)
attention · followthrough · objectivespublished documents · read
ask/query · ask
events.head · read · subscribe · on/events · /events/stream · subscribe
propose · proposals.list/get/withdraw/report/awaitResolution/propose · /proposals* · propose
mcp.tools · mcp.call/mcp · read, or ask alone (the answer tools; bevia_capture with capture)
exportSubstrate/export-substrate · substrate_export (owner-grant)
whoami · health/whoami · /health

Every failure is a BeviaError with status, code, body and, on a 401, the capability the door needs.

Python

A stdlib-only reference client, one file, no dependencies: examples/python/bevia.py in the SDK package. Copy it next to your script. Same doors, same events, same proposals.

from bevia import connect_local

bevia = connect_local()                       # ~/Bevia/Developer/bevia-workspace.json
print(bevia.whoami())
print(bevia.world_history(3))
for ev in bevia.events(kinds=["attention.created"]):   # server-sent events; blocks
    print(ev["data"]["headline"])

Any language

The SDK is a convenience. The contract is the protocol document Bevia writes into every developer workspace as PROTOCOL.md and serves at /build/PROTOCOL.md. A coding agent starts from /build/AGENTS.md and the app-builder skill, both shipped in the SDK's source. If you can speak HTTP to localhost, you can build for Bevia in Rust, Swift, Go, a shell script, an n8n workflow, or a language that does not exist yet.

curl -s http://127.0.0.1:$PORT/whoami -H "Authorization: Bearer $TOKEN"
curl -N http://127.0.0.1:$PORT/events/stream -H "Authorization: Bearer $TOKEN"

Input / sensors →