Metadata-Version: 2.5
Name: vexinter
Version: 0.5.7
Summary: Verification, memory, and secure communication infrastructure for AI agents
Author: Vexinter Team
License: LicenseRef-Fair-Source (Community), see LICENSE-COMMUNITY.md
License-File: LICENSE-COMMUNITY.md
Classifier: License :: Other/Proprietary License
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.11
Requires-Dist: cryptography>=42
Requires-Dist: httpx>=0.27
Requires-Dist: jsonschema>=4.21
Requires-Dist: numpy>=1.26
Requires-Dist: prometheus-client>=0.19
Requires-Dist: pydantic>=2.7
Provides-Extra: dev
Requires-Dist: jinja2>=3.1; extra == 'dev'
Requires-Dist: mypy; extra == 'dev'
Requires-Dist: psycopg[binary,pool]; extra == 'dev'
Requires-Dist: pytest-cov; extra == 'dev'
Requires-Dist: pytest>=8; extra == 'dev'
Requires-Dist: python-multipart>=0.0.9; extra == 'dev'
Requires-Dist: ruff; extra == 'dev'
Requires-Dist: testcontainers>=4.6; extra == 'dev'
Provides-Extra: distributed
Requires-Dist: redis>=5.0; extra == 'distributed'
Provides-Extra: llm
Requires-Dist: openai>=1.30; extra == 'llm'
Provides-Extra: memory
Requires-Dist: sqlite-vec>=0.1; extra == 'memory'
Provides-Extra: server
Requires-Dist: fastapi>=0.110; extra == 'server'
Requires-Dist: jinja2>=3.1; extra == 'server'
Requires-Dist: psycopg[binary,pool]; extra == 'server'
Requires-Dist: python-multipart>=0.0.9; extra == 'server'
Requires-Dist: uvicorn[standard]; extra == 'server'
Description-Content-Type: text/markdown

# Vexinter

**Verification, memory, and secure communication infrastructure for AI agents.**

> Developer documentation: **https://vexinter.com/docs**

Vexinter sits between your AI agents and the real world, providing three
fundamental layers that ensure every decision is verifiable, every memory is
useful, and every message is private:

| Layer                        | Function                                                                 | Example                                                                                  |
| ---------------------------- | ------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------- |
| **Operational Verification** | Declarative policies, per-action attestation, immutable log              | A refund agent can only execute if `amount <= 500` and the customer is verified          |
| **Dynamic Memory**           | Episodic/semantic/working memory, controlled retention, tenant isolation | Historical context that evolves with the agent and complies with GDPR (right to erasure) |
| **Secure Communication**     | E2E channels between agents, verifiable identity, granular permissions   | Agent A sends an order to Agent B with non-repudiation and integrity checks              |

---

## Features

- **Verifiable execution**: tasks run under declarative conditions; every tool
  call is attested and appended to a hash-chained, append-only audit log.
- **Memory with governance**: episodic/semantic/working memory tiers,
  retention policies, per-person GDPR erasure that preserves chain integrity.
- **Cryptographic identity**: Ed25519 agent keys, rotation, nonces, signed
  envelopes; X25519 E2E encrypted messaging interoperable across SDKs.
- **FastAPI service**: signed data plane + admin control plane, automatic
  PostgreSQL schema migration, rate limiting, circuit breaker, optional Redis.
- **Web console**: React/Vite SPA served at `/app` with HttpOnly-cookie auth,
  i18n and theme support.
- **Observability**: Prometheus metrics (`/metrics`), OpenAPI spec
  (`/openapi.json`), health/readiness endpoints.
- **Multi-tenancy**: tenant records with tiers, agent binding, suspension and
  per-tier execution quotas.
- **SDKs**: Python (`vexinter.sdk` sync + `vexinter.remote` async) and
  TypeScript (`@vexinter-ai/sdk` on npm).

---

## Quickstart

### Docker Compose (recommended)

```bash
cp .env.example .env
# Edit .env: POSTGRES_PASSWORD and VEXINTER_ADMIN_TOKEN are required
docker compose up --build
```

Endpoints:

- **API / Console**: http://localhost:8000/app
- **Prometheus Metrics**: http://localhost:8000/metrics
- **OpenAPI Spec**: http://localhost:8000/openapi.json
- **Health**: http://localhost:8000/health (also `/ready`, `/live`, `/health/full`)

The compose file fails fast if required secrets are missing, does not expose
the PostgreSQL port, and runs the service as a non-root user with a
`HEALTHCHECK` and CPU/memory limits (`VEXINTER_CPUS` / `VEXINTER_MEMORY`).

**Production notes**

- **TLS**: the container does not terminate TLS, put a reverse proxy in
  front (Caddy/Nginx/Traefik). Session cookies default to `Secure` +
  `SameSite=Strict`; keep `VEXINTER_COOKIE_SECURE=1` behind HTTPS.
- **Secrets**: `.env` is fine for a single host; for orchestrated deploys
  prefer Docker secrets / your secret manager and drop `env_file`.
- **Scaling**: multiple replicas are safe for the API (Postgres-backed
  sequence guard and rate limiting), but keep `VEXINTER_SCHEDULER_INTERVAL_S`
  enabled on **one** replica only, follow-up scheduling is not
  leader-elected.

### Synchronous SDK

```python
from vexinter.sdk import Task
from vexinter.core.runtime import LocalRuntime
from vexinter.demo import CrmAdapter, BillingAdapter

rt = LocalRuntime([CrmAdapter(), BillingAdapter()])

with Task(
    rt,
    agent="soporte_bot",
    objective="Customer signup and invoice",
    condition={"op": "equals", "a": {"from": "crm", "path": "status"}, "b": "active"},
    input={"email": "client@example.com"}
) as t:
    c = t.tools.crm.create_customer({"name": "John Doe", "email": "client@example.com"})
    t.tools.billing.create_invoice({"customer_id": c.id, "amount": 150})
    verdict = t.verify()
    print(f"Status: {verdict.status}")  # "met" | "not_met" | "inconclusive"
```

### Async SDK

```python
import asyncio
from vexinter.remote import AsyncRemoteRuntime, AsyncRemoteTask
from vexinter.identity import AgentKeyMaterial

async def main():
    keys = AgentKeyMaterial.generate()
    async with AsyncRemoteRuntime("http://localhost:8000") as rt:
        async with AsyncRemoteTask(
            rt, agent="bot-async", objective="Asynchronous verification",
            condition={"op": "equals", "a": {"from": "system", "path": "ok"}, "b": True}
        ) as t:
            res = await t.tools.system.ping({"ping": True})
            print("Result:", res)

asyncio.run(main())
```

### GDPR erasure

```python
from vexinter.privacy import InMemoryKeyRing, PrivacyStore
from vexinter.store_pg import PostgresEventStore

inner = PostgresEventStore("postgresql://user:pass@localhost:5432/db")
store = PrivacyStore(inner, InMemoryKeyRing())

# Sensitive data is encrypted at rest and redacted in logs.
# Right to erasure (Art. 17 GDPR): destroys content, preserves integrity.
store.erase(execution_id="exec_12345", reason="data subject request")
assert store.verify_chain("task:exec_12345").ok
```

**Erasure limitations (read before relying on this for compliance):**

- `FileKeyRing.destroy()` overwrites the key file and deletes it, but a
  journaled filesystem or SSD does not guarantee _physical_ erasure,
  forensic recovery of the raw key bytes cannot be ruled out. For
  high-assurance deployments, keep the key directory on a separate
  volume excluded from backups, or front it with an HSM/KMS.
- Erasure renders content unreadable (crypto-shredding); the ciphertext
  itself remains in the append-only log. Whether encrypted-but-intact
  records satisfy a given erasure request is a legal question that
  depends on jurisdiction and retention policy, have counsel validate
  the approach for your deployment.
- Anti-replay sequence state for agent-to-agent envelopes is rebuilt
  from the persistent log on startup (`restore_from_log`), but it is
  per-process: multi-node deployments must route a given agent pair
  through a single node or add a shared sequence store.

---

## Installation

### Community (source)

```bash
git clone https://github.com/Vexinter-AI/vexinter.git
cd vexinter
python -m venv .venv && source .venv/bin/activate
pip install -e ".[dev]"
```

### Paid plans (signed wheels via the billing endpoint)

Subscribers receive a **license token** (secret) and **customer id**
(`lic_…`) by email after purchase. Configure pip once via `~/.netrc`
(`chmod 600`):

```
machine billing.vexinter.com login lic_xxxxxxxxxxxxxxxx password <token>
```

then install the signed wheel:

```bash
pip install https://billing.vexinter.com/pro/vexinter_pro-<version>-py3-none-any.whl
```

---

## Licensing and commercial model

Vexinter is **source-available** under the
[Community License](LICENSE-COMMUNITY.md): free for
non-commercial use (personal projects, hobby, education, research,
evaluation, and nonprofit/government entities).

Commercial use, including **internal use inside for-profit organizations**
to automate business processes, requires a paid [subscription](https://vexinter.com/#pricing)
(Professional / Business). See the
[Terms of Service](TERMS-OF-SERVICE.md) and the
[license page](https://vexinter.com/license).

Paid plans add: signed wheels and updates via the billing package
endpoint, higher task quotas, priority/dedicated support, and signed
license documents that enforce plan limits automatically on the instance.

### How enforcement works

Each customer gets an Ed25519-signed license document served by the vendor's
billing endpoint (`GET /license/{customer_id}.json`). The instance fetches it
at most once per day, verifies the signature against the bundled vendor root key,
caches the last valid document for up to 7 days while the endpoint is
unreachable, and applies the resulting plan. After the paid period ends,
a cancelled or expired subscription degrades to Community limits within
~24h of the license document reflecting it, with no client action.
Validation is fully offline; the vendor backend only _issues_
documents.

The vendor-side commercial backend (payment webhooks → package credentials →
transactional emails → license issuing) is operated by Vexinter as a managed
service; customers never need to run or configure it.

---

## Architecture

```
┌────────────────────────────────────────────────────────────┐
│                      AGENT / CLIENT                        │
│  ┌──────────────────────────────────────────────────────┐  │
│  │ vexinter.sdk.Task    vexinter.remote.AsyncRemoteTask │  │
│  └──────────────────────────────────────────────────────┘  │
└──────────────────────────┬─────────────────────────────────┘
                           │ HTTPS + Ed25519 Signed Requests
                           ▼
┌────────────────────────────────────────────────────────────┐
│                    VEXINTER SERVICE (FastAPI)              │
│  ┌──────────────────┐  ┌────────────────────────────────┐  │
│  │ Data Plane       │  │ Control Plane (Admin)          │  │
│  │ /v1/tasks        │  │ /v1/identity/*                 │  │
│  │ /v1/messages     │  │ /v1/cases, /v1/followups       │  │
│  │ /v1/memory       │  │ /v1/metrics, /v1/checkpoints   │  │
│  └──────────────────┘  └────────────────────────────────┘  │
│                           │                                │
│              ┌────────────┴────────────┐                   │
│              ▼                         ▼                   │
│      ┌─────────────┐           ┌──────────────┐            │
│      │ PostgreSQL  │           │  Console     │            │
│      │ (Events +   │           │  React/Vite  │            │
│      │  Hashchain) │           │  (/app)      │            │
│      └─────────────┘           └──────────────┘            │
└────────────────────────────────────────────────────────────┘
```

---

## Configuration

| Variable                                             | Required      | Description                                                  |
| ---------------------------------------------------- | ------------- | ------------------------------------------------------------ |
| `POSTGRES_PASSWORD`                                  | Yes (compose) | PostgreSQL password                                          |
| `VEXINTER_PG_DSN`                                    | No\*          | PostgreSQL DSN; defaults to `InMemoryEventStore`             |
| `VEXINTER_AUTO_MIGRATE`                              | No            | `"1"` (default) applies schema on startup                    |
| `VEXINTER_ADMIN_TOKEN`                               | No\*\*        | Control-plane token; without it the service runs in dev mode |
| `VEXINTER_DEV_MODE`                                  | No            | `"1"` disables auth, **development only**                    |
| `VEXINTER_ADAPTERS`                                  | No            | `"module:Class,other:Factory"` custom connectors             |
| `VEXINTER_OPERATOR_TOKENS`                           | No            | `name:token[:role[:expires]]` for decision attribution       |
| `VEXINTER_COOKIE_SECURE`                             | No            | `"1"` for `Secure` cookies behind HTTPS                      |
| `VEXINTER_METRICS_TOKEN`                             | No            | Read-only token for `/metrics` (12+ chars)                   |
| `VEXINTER_LOGIN_MAX_FAILS` / `VEXINTER_LOGIN_LOCK_S` | No            | Login lockout (default: 5 / 900s)                            |
| `VEXINTER_REDIS_URL`                                 | No            | Optional Redis for rate limit, circuit breaker, coordination |
| `VEXINTER_GDPR_INDEX_PATH`                           | No            | Disk cache for the GDPR person index (event-sourced)         |
| `VEXINTER_GDPR_LOG_PATH`                             | No            | Optional JSONL mirror of completed GDPR erasures             |
| `VEXINTER_RATE_LIMIT_RPS` / `VEXINTER_RATE_LIMIT_BURST` | No | Middleware rate limit |
| `VEXINTER_KEYRING_DIR` | No | File keyring dir for `PrivacyStore` |
| `VEXINTER_KEYS_DB_PATH` / `VEXINTER_KEYS_PASSWORD` / `VEXINTER_KEYS_SALT` | No | Encrypted agent-key persistence |
| `VEXINTER_LICENSE_BASE_URL` / `VEXINTER_LICENSE_ID` / `VEXINTER_LICENSE_TOKEN` | No | Signed license endpoint, customer id, secret token (root pubkey is embedded in `vexinter-pro`) |
| `VEXINTER_LICENSE_CACHE` | No | Cache file for the last valid license document |
| `VEXINTER_LICENSE_MAX_STALE_S` | No | Stale-cache cap in seconds (default 7 days; `-1` = unlimited, for offline licenses) |
| `VEXINTER_DEFAULT_PLAN` | No | Plan when no license doc applies (default: `community`) |
| `VEXINTER_MAX_STEPS` / `VEXINTER_TASK_DEADLINE_S` | No | Per-execution caps: 100 tool calls / 1800s |
| `VEXINTER_LOOP_THRESHOLD` / `VEXINTER_CYCLE_THRESHOLD` | No | Loop guards: 3 identical calls / 3 cycle repeats |
| `VEXINTER_NO_PROGRESS_WINDOW` | No | Calls without a new outcome before a violation (8) |
| `VEXINTER_MAX_SUBTASK_DEPTH` / `VEXINTER_MAX_SUBTASKS_PER_TASK` | No | Delegation bounds: depth 3 / 32 subtasks per task |
| `VEXINTER_DEFAULT_MAX_TOKENS` / `VEXINTER_COMMUNITY_MAX_TOKENS` | No | Token caps: 100k default / 50k Community ceiling |

With `VEXINTER_PG_DSN` set, the event log is PostgreSQL-backed and
`TierUsage` quotas, `TenantService` membership/tier state, and the GDPR
person index and erasure requests all survive restarts and work across
multiple workers. With `InMemoryEventStore` they are per-process only.

See `.env.example` for the complete annotated list.

### Authentication

- **SPA / console**: `POST /v1/auth/login` exchanges the token for an
  **HttpOnly session cookie** (`vex_spa`, HMAC-signed, `SameSite=Lax`,
  optional `Secure`, 8h). The token is never stored in `localStorage`.
- **Non-browser clients** (SDK, scripts, Prometheus): `X-Vex-Admin` header or
  `Authorization: Bearer`.

### Multi-tenancy

Tenant records (name, tier, status, members with roles, per-tier quotas) live
in `vexinter/core/multitenancy.py` and are enforced by the service:

- **Agent binding**: `POST /v1/admin/tenants/{id}/agents`, bound agents
  inherit tenant status; suspending a tenant rejects its agents with 403.
- **Execution quota**: `POST /v1/tasks` returns 429 past the tier's daily cap.
- **Admin API** (admin token required): `POST/GET /v1/admin/tenants`,
  `GET /v1/admin/tenants/{id}`, `POST .../suspend|activate`, members and agent
  bind/unbind endpoints.
- Tenant lifecycle events go to the append-only audit log.
- **Persistence**: with `VEXINTER_PG_DSN` (Postgres store) tenants, members,
  agent bindings and daily usage counters live in `vex_tenant*` tables and
  survive restarts; usage increments are atomic (`INSERT ... ON CONFLICT`).
  With the in-memory store everything stays process-local, as before.

> **Isolation scope**: enforcement is per-agent, a credential resolves to an
> agent, the agent to its tenant, and the tenant's status/quota apply. The
> event store itself is a single shared log: queries are not row-filtered by
> tenant, so cross-tenant reads are prevented by credential scoping, not by
> storage-level separation.

### Tasks, quota and guardrails

A **task** is one accepted objective execution (`POST /v1/tasks`): it
starts when the objective is accepted and ends in a terminal state
(met / not_met / inconclusive / failed / cancelled). Quota semantics:

- **Counted at acceptance**, before execution, failed, aborted and
  cancelled tasks consume the same single unit as successful ones.
- **Never double-charged on retry**: pass `idempotency_key` and a
  network-cut retry returns the same task (`deduplicated: true`);
  reusing the key with a different payload returns `409`.
- **Rejections are free**: invalid conditions (422), auth failures,
  tenant quota (429) and tier-limit denials (403) consume no quota.
- **Sub-tasks are not separate quota units**: `POST
/v1/tasks/{id}/subtasks` (including cascades from a sub-task id)
  inherits the parent's budget and is bounded by
  `VEXINTER_MAX_SUBTASK_DEPTH` (default 3) and
  `VEXINTER_MAX_SUBTASKS_PER_TASK` (default 32); over-limit delegation
  returns 429.
- **Plan resolution**: a paid plan requires a verified license
  document (`VEXINTER_LICENSE_*`) **and** the `vexinter-pro` package,
  the paid features and the license-validation code are not in the
  public repository, so a paid plan cannot be activated from the
  public tree alone. (The Community 500 tasks/month cap is a constant
  in the public source: the license is the legal enforcement, not the
  code.) Paid tiers (Professional 5,000 / Business 50,000) are
  registered at runtime by `vexinter-pro` and bound to the signed
  document's `max_instances` (Professional: 5 concurrent instances,
  Business: unlimited).
  `VEXINTER_DEFAULT_PLAN` is honored only in dev mode, and an
  unreachable license degrades to community, env vars alone never
  unlock paid tiers. On multi-tenant deployments an agent bound to a
  tenant inherits the tenant's tier (professional→professional,
  enterprise→business) and the tenant id keys its own usage bucket,
  so customers get per-tenant quotas.

  Subscribers install the private package using the **secret token**
  from their welcome email, keep it in `~/.netrc`, never in URLs:

  ```bash
  # ~/.netrc (chmod 600)
  machine billing.vexinter.com login lic_xxxxxxxxxxxxxxxx password <token>

  pip install https://billing.vexinter.com/pro/vexinter_pro-<version>-py3-none-any.whl
  ```

  The endpoint only serves the wheel while the license is active,
  cancelled/expired subscriptions get HTTP 401/403.

Every execution is bounded by conservative defaults, overridable per
task at creation:

| Limit                         | Default                         | Override             |
| ----------------------------- | ------------------------------- | -------------------- |
| Tool-call attempts            | `VEXINTER_MAX_STEPS=100`        | `max_steps`          |
| Wall-clock deadline           | `VEXINTER_TASK_DEADLINE_S=1800` | `deadline_s`         |
| Identical-call loop           | `VEXINTER_LOOP_THRESHOLD=3`     | `loop_threshold`     |
| Call-pattern cycle (A-B-A-B…) | `VEXINTER_CYCLE_THRESHOLD=3`    | `cycle_threshold`    |
| No-progress window            | `VEXINTER_NO_PROGRESS_WINDOW=8` | `no_progress_window` |

Budgets (`max_tokens`, `max_usd`, `model_pricing`) are optional;
`max_tokens` is the primary bound because `max_usd` depends on the
client-supplied pricing table. On the Community plan `max_tokens` is
hard-capped at `VEXINTER_COMMUNITY_MAX_TOKENS` (default 50,000); other
plans default to `VEXINTER_DEFAULT_MAX_TOKENS` (100,000) when unset.
Tasks created without any budget field return a `warnings` entry.

Python SDKs accept the same knobs:

```python
from decimal import Decimal
from vexinter.models.budget import Budget
from vexinter.remote import AsyncRemoteRuntime, AsyncRemoteTask

budget = Budget(max_tokens=20_000, max_steps=60, deadline_s=900)
async with AsyncRemoteTask(
    rt, agent="bot", objective="...", condition={...},
    idempotency_key="order-12345", budget=budget,
) as t:
    ...
```

---

## Observability

Prometheus metrics are derived exclusively from the append-only event log:

```
vexinter_executions_total
vexinter_final_states{state="met|not_met|inconclusive|..."}
vexinter_false_successes_total
vexinter_discrepancies_total
vexinter_retries_compensations_total
vexinter_human_decisions_requested_total / _made_total
vexinter_rejected_operations_total
vexinter_authentication_errors_total
vexinter_integrity_failures_total
vexinter_message_rejections / vexinter_tool_rejections (by reason)
```

---

## Tests

```bash
pytest -v                              # full suite (testcontainers + Docker)
pytest -m "not pg and not live" -v     # unit tests only (no DB)
cd packages/sdk-ts && npm test         # TypeScript SDK tests
```

Current result: **326 passed, 5 skipped** (Python) + SDK tests. `ruff` and
`mypy` are clean.

---

## Project structure

```
Vexinter/
├── packages/sdk-ts/        # TypeScript SDK (@vexinter-ai/sdk, public npm)
├── vexinter/               # Python package
│   ├── core/               # events, store, crypto, state machine, verifier,
│   │                       #   licensing, multitenancy, gdpr_erasure, ...
│   ├── identity/           # Ed25519 identity, envelopes, messaging
│   ├── privacy/            # PrivacyStore, KeyRing, E2E encryption
│   ├── remote.py           # AsyncRemoteRuntime / AsyncRemoteTask
│   ├── sdk.py              # Task / LocalRuntime high-level SDK
│   ├── store_pg.py         # PostgreSQL EventStore + SequenceGuard
│   ├── demo.py             # Example adapters (CRM, Billing)
│   └── app/                # Web console (React + Vite + Tailwind)
├── services/app.py         # FastAPI server (API + console + metrics + webhooks)
├── sql/schema.sql          # PostgreSQL schema
├── tests/                  # pytest suite (unit + PG integration)
├── examples/               # demos and benchmarks
├── .github/workflows/      # CI (ruff+mypy+pytest), publish, sdk-ts release
├── Dockerfile / docker-compose.yml / .env.example
├── LICENSE-COMMUNITY.md   # Source-available license (free → MIT after 2y)
├── TERMS-OF-SERVICE.md     # Commercial terms
└── SECURITY.md             # Vulnerability reporting policy
```

---

## Links

- Website & pricing: https://vexinter.com
- Terms of Service: https://vexinter.com/terms
- License: https://vexinter.com/license
- Security policy: [SECURITY.md](SECURITY.md)

## Support

- Community: GitHub issues on `Vexinter-AI/vexinter`
- Paid plans: `support@vexinter.com` (Professional: 48h response SLA,
  Business: 8h response SLA). Include your **customer ID** (`lic_…`,
  shown in your welcome email and as `VEXINTER_LICENSE_ID` in `.env`)
  so we can verify your plan and apply the SLA, it is also visible in
  the footer of every billing email.

---

_v0.5.1, November 2026_
