How it works

Three packages and a command line.

An app installs Teovo's packages together. The app keeps its own tools, rules, sign-in and database; Teovo owns the chat panel, the server handler and its own tv_ tables.

Architecture

Browser
App screensuseAssistantContext({ path, title, record })
@teovo/reactAssistantProvider + AssistantPanel
POST /chat (new message only) UI message stream: text, data-step, data-card, data-action, data-suggestions Confirm, skip, undo a card · suggestions · settings
App server · Node, Cloudflare Workers, Cloud Run
@teovo/servercreateAssistant(config).fetch
Tool loopVercel AI SDK streamText
App callbacksidentify, asUser, tools, cards, screen, suggestions
Model 1; Model 2 if the first fails before any output tv_ tables App's tables, as the signed-in user (row-level rules)
Models
Model 1e.g. Gemini
Model 2backup
Postgres
@teovo/db: tv_ tablesthreads, messages, runs, steps, usage, budgets, settings, proposals
App's own tables
Terminal or CI
npx teovoinit, generate, migrate, status, prune → tv_ tables

Highlighted boxes are Teovo; the rest is your app.

Packages

PackageRuns inHolds
@teovo/serverThe app's own serverThe handler, tool loop, cards, limits, run log, screens, suggestions, tenant settings
@teovo/reactThe browserThe provider, the panel, cards, chips, and the screen-context hook
@teovo/dbPostgresMigrations (tables follow the features that are on), row-level rules, the storage adapter, prune
teovoA terminal or CInpx teovo init, generate, migrate, status, prune

One message, start to finish

  1. The panel sends only the new message, the thread id and the screen (path, title, open record). The server keeps the history.
  2. The handler asks the app who the user is (identify). No identity means 401.
  3. It checks the tenant's settings (switched off means 403) and the limits: replies running at once, then messages and tokens for the person and the tenant, by day or month. Over a limit means 429 with a sentence. Nothing is saved before these checks pass.
  4. It loads the thread, but only one that belongs to this tenant and this user (otherwise 404), and the last 30 messages. Earlier cards are given to the model with their status now: confirmed, skipped, undone or expired.
  5. It builds the system prompt in a fixed order: the app's instructions; the tenant's notes and glossary; the rule for untrusted text; the screen, fenced as untrusted because the browser and the records supplied it.
  6. The tool loop runs on the first model; if that fails before saying anything, the next one is tried. Tools come in three kinds:
    • read looks something up, as the user (asUser).
    • propose returns a card and changes nothing.
    • action offers a button.
    Tools a role may not use, or the tenant switched off, are never offered.
  7. Text, tool steps, cards and buttons stream to the panel. Follow-up suggestions are sent last, as a transient part that is not saved.
  8. The run, each tool step and the token usage are saved, on the model that actually answered.
  9. The user presses Confirm. POST /cards/:id/confirm finds the card in the user's own threads, checks the record hasn't changed since the card was prepared, and claims the card with a compare-and-set, so a double tap applies once. Then it calls the app's own apply as the user. Undo works for 10 minutes for the person who confirmed.

Endpoints

Mounted under one path in the app's server, e.g. app.all('/api/assistant/*', teovo.fetch).

CallPurpose
POST /chatSend a message; the reply streams back. Header x-teovo-thread carries the thread id
POST /cards/:id/confirm, /skip, /undoDecide a card
GET /suggestions?path&title&recordType&recordIdChips and the input hint for a screen
GET /settings, PUT /settingsA tenant's own settings (owner and admin)
GET /threads, GET /threads/:id, POST /threads/:id/archiveList, reopen and remove conversations
POST /threads/:id/views/:viewId/submitSend a form the assistant showed; it becomes a card

Planned: ratings, data wipe, run events for long runs.

Stream parts

Teovo uses the Vercel AI SDK's UI message stream, so its React hooks read it as is.

PartCarries
textThe reply
data-stepA tool starting and finishing, updated in place by id
data-cardA change to confirm, with before and after values (never the undo data)
data-actionA button: open a screen or run an app action
data-suggestionsFollow-up chips (transient, not saved)
data-viewA view the assistant showed (choices, table, record, form, or the app's own), drawn by the panel

Tables

All prefixed tv_. Core tables are always created; a feature's tables only when the feature is on.

TableHolds
tv_threads, tv_messagesConversations, per tenant and user
tv_runs, tv_run_stepsOne row per reply, one per tool call
tv_usage, tv_usage_dailyEach usage event, and daily totals per person and per tenant
tv_budgetsA tenant's own limits, overriding the code's
tv_tenant_settingsOn/off, notes, glossary, tools off
tv_proposalsCards and their decisions (feature proposals)
tv_migrationsWhich migrations ran

With row-level rules on, every table gets rules built from the app's own tenancy, for example { tenant: 'public.current_business_id()::text', user: 'auth.uid()::text' } on Supabase.

Get started Architecture doc on GitHub