# OsBase

> The database product: agents work on Postgres, Supabase, Neon or D1 through a bridge, with a change journal, undo, approvals and sight levels.

Source: https://osevel.com/docs/products/osbase/

OsBase is the database product of Osevel, and the first one. It puts a bridge between your AI
agents and your database: agents connect through Osevel, never with your database password.
Every write is recorded row by row so it can be undone, risky changes wait for your approval,
and each agent sees only as much of your data as you allow.

This page is the overview. Each part has its own page, linked below.

- [What it protects against](#what-it-protects-against)
- [Which databases](#which-databases)
- [Set up](#set-up)
- [How it works](#how-it-works)
- [What an agent sees](#what-an-agent-sees)
- [With the other Os products](#with-the-other-os-products)
- [Limits](#limits)
- [All OsBase pages](#all-osbase-pages)

## What it protects against

- **One wrong statement.** A `DELETE` without a `WHERE`, or an `UPDATE` on the wrong table, is
  recorded with the rows as they were before and after. You undo one change or a whole agent
  session.
- **Changes nobody looked at.** Your policy decides which writes go through and which wait for
  a person. Schema changes always wait.
- **An agent reading your customers.** By default an agent gets answers about rows without the
  values in them.
- **Not knowing who did what.** Each agent has its own name and token; the change journal says
  which agent made each change.

## Which databases

| Database                           | Page                                  |
| ---------------------------------- | ------------------------------------- |
| Your own PostgreSQL                | [Getting started](https://osevel.com/docs/getting-started/install/) |
| Supabase                           | [Supabase](https://osevel.com/docs/guides/supabase/)               |
| Neon                               | [Neon](https://osevel.com/docs/guides/neon/)                       |
| Cloudflare D1                      | [Cloudflare D1](https://osevel.com/docs/guides/cloudflare-d1/)                |
| A Postgres hosted by Osevel (beta) | [Hosted Postgres](https://osevel.com/docs/hosted/overview/)          |

The exact versions that were tested are on each page.

## Set up

```bash
npm i -g @osevel/cli
```

```bash
osevel init
```

`init` asks for the admin connection, the schemas agents may use and a confirmation code, then
installs the journal and the agent roles in one transaction. [Getting started](https://osevel.com/docs/getting-started/install/)
walks through every prompt, connecting your MCP client, and a first approval and undo.

## How it works

1. **Agents connect through Osevel.** You register each agent by name with an access level:
   `read`, `write` or `schema`. It gets only the tools of its level. See [agents](https://osevel.com/docs/guides/agents/).
2. **Policy decides each write.** A write goes through, waits for approval or is refused. You
   approve at the terminal with a typed code, or in the dashboard with your passkey. See
   [usage](https://osevel.com/docs/getting-started/usage/).
3. **Every write is journaled.** The journal keeps each row a change touched, before and after.
4. **Undo.** `osevel undo` takes back one change or a whole session. Schema changes have their
   own undo classes; see schema changes.

Beyond raw SQL, you can give agents named operations with typed arguments
([capabilities](https://osevel.com/docs/guides/capabilities/)), run agents that decide by rules without a model
([rules](https://osevel.com/docs/guides/rule-based-agents/)), and run local agents in a container that reaches only its model provider
([sandbox](https://osevel.com/docs/guides/sandbox/)). A team shares one bridge that holds the credentials
([team bridge](https://osevel.com/docs/guides/team-bridge/)).

## What an agent sees

Every agent has a level of sight:

| Sight       | What the agent gets                                                      |
| ----------- | ------------------------------------------------------------------------ |
| `structure` | Tables and columns only.                                                 |
| `shape`     | Answers about rows without their values. The default.                    |
| `masked`    | Rows, with private columns replaced by stand-ins such as `email_9f3c1a`. |
| `clear`     | May ask for a timed reveal, which a person grants.                       |

```bash
osevel agent sight cursor-main masked
```

Raising sight asks for the confirmation code. Lowering needs none. Details, column classes and
reveals are in [agents](https://osevel.com/docs/guides/agents/).

## With the other Os products

- [OsBrain](https://osevel.com/docs/products/osbrain/) judges every agent write and schema change once more against your
  cross-product rules, and lists database approvals next to held API calls.
- [OsApi](https://osevel.com/docs/products/osapi/) covers what OsBase cannot: calls to your database provider's own API
  (delete a Neon branch, a Supabase project), which never pass through SQL.
- [OsVault](https://osevel.com/docs/products/osvault/) keeps the other keys your agents use. OsBase's own database credentials
  are held by the bridge, not by a vault.

## Limits

- **Undo covers what went through Osevel.** A change made by your app, or by anyone connecting
  directly, is not in the journal. The foreign connection watch can cut clients that are not
  declared.
- **Masking hides values from agents**, not from you or your own application.
- **Against an agent with a shell as your OS user**, the default mode does not protect the stored
  role passwords. Daemon mode does; see the [security model](https://osevel.com/docs/security/model/).
- **Hosted Postgres is a beta** with its own limits; see [hosted Postgres](https://osevel.com/docs/hosted/overview/).
- The full lists: [limitations](https://osevel.com/docs/reference/limitations/) and [security model](https://osevel.com/docs/security/model/).

## All OsBase pages

- [Getting started](https://osevel.com/docs/getting-started/install/): from install to a first undo.
- [Using osevel](https://osevel.com/docs/getting-started/usage/): the commands, day to day.
- [Agents](https://osevel.com/docs/guides/agents/): access levels, sight, handoffs, notes.
- [Capabilities](https://osevel.com/docs/guides/capabilities/): named operations instead of raw SQL.
- [Rule-based agents](https://osevel.com/docs/guides/rule-based-agents/) and the [sandbox for local agents](https://osevel.com/docs/guides/sandbox/).
- [Team bridge](https://osevel.com/docs/guides/team-bridge/): one bridge for a team.
- [Supabase](https://osevel.com/docs/guides/supabase/), [Neon](https://osevel.com/docs/guides/neon/), [Cloudflare D1](https://osevel.com/docs/guides/cloudflare-d1/), [hosted Postgres](https://osevel.com/docs/hosted/overview/).
- Schema changes and finding slow queries.
- [Security model](https://osevel.com/docs/security/model/) and [limitations](https://osevel.com/docs/reference/limitations/).
