# runvendo/vendo architecture

> Architecture diagram of the GitHub repository runvendo/vendo, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-22). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/runvendo/vendo
- Repository: https://github.com/runvendo/vendo

## Overview

#### Purpose and entry points
Vendo is a TypeScript monorepo for embedding a guarded, streaming AI customization layer into host products. It extracts host APIs into tools, generates customer-owned UI/apps, and supports approved automations. The default SDK/composition and CLI are `packages/vendo/src/index.ts`, `packages/vendo/src/server.ts`, and `packages/vendo/src/cli.ts`; executable entry is `packages/vendo/bin/vendo.mjs`. Thin compatibility alias: `packages/vendoai/src/index.ts`.

#### Core contracts and UI document pipeline
`@vendoai/core` defines shared identity, principals, grants, tool envelopes, app documents, and generated UI tree/wire formats. The v2 compiler and patch/shape validation make generated UI structured rather than arbitrary frontend code.
- `packages/core/src/app-document.ts`
- `packages/core/src/tree-v2.ts`
- `packages/core/src/wire-v2/compile.ts`

Generated trees are rendered by the React UI package using a component registry and bindings. Untrusted/generated components can run in a jailed iframe runtime; host-mounted/in-client views are a distinct boundary.
- `packages/ui/src/tree/renderer-v2.tsx`
- `packages/ui/src/tree/jail/JailedComponent.tsx`
- `packages/ui/src/kit/registry.ts`

#### Host integration and tool extraction
The CLI initializes and maintains `.vendo/` host metadata, scans APIs/routes and schemas, extracts theme/semantics, and proposes reviewable wiring. Sync adapters support OpenAPI, route scans, GraphQL, tRPC, and server actions.
- `packages/vendo/src/cli/init.ts`
- `packages/vendo/src/cli/sync.ts`
- `packages/actions/src/sync/route-scan.ts`

At runtime, Actions normalizes extracted host API, connector, and compound tools into a searchable registry. Auth presets and host-file adapters bridge host identity and execution environments, including edge-oriented variants.
- `packages/actions/src/runtime/registry.ts`
- `packages/actions/src/connectors/mcp.ts`
- `packages/actions/src/presets/index.ts`

#### Agent execution and safety choke point
The Agent package owns conversation threads, context packing, model streaming, tool selection, and iterative execution. It is model-provider-oriented rather than tied to a specific agent framework.
- `packages/agent/src/agent.ts`
- `packages/agent/src/runner.ts`
- `packages/agent/src/threads.ts`

Every consequential tool/app action crosses Guard, which evaluates policy and risk, creates single-use approval flows, enforces grants/breakers, and writes audit outcomes. This separates model intent from authorized execution.
- `packages/guard/src/guard.ts`
- `packages/guard/src/policy.ts`
- `packages/guard/src/judge.ts`

#### Apps, sandboxing, and automations
Apps turns agent output into versioned app records and machine lifecycles: generation/edit pipeline, run/ship diffs, persistence, pins, and sandbox adapters. The sandbox/box layer is the escalation boundary for server-capable generated behavior.
- `packages/apps/src/engine.ts`
- `packages/apps/src/machine-lifecycle.ts`
- `packages/apps/src/sandbox.ts`

Automations ingests schedules, host events, and external triggers, then runs app-bound work through the same guarded path; it maintains engine-level run behavior rather than bypassing safety.
- `packages/automations/src/engine.ts`
- `packages/apps/src/schedules.ts`
- `packages/apps/src/automation-plan.ts`

#### Persistence, external surfaces, and runtime
Store provides the durable isolation boundary for tenants/principals, threads, grants, app rows, audit, blobs, encrypted secrets, retention, and compare-and-swap semantics. It supports PGlite default/local operation and Postgres production backends.
- `packages/store/src/store.ts`
- `packages/store/src/db.ts`
- `packages/store/src/secrets.ts`

Optional external integrations include Composio connectors, MCP exposure with OAuth/consent, cloud-gated services, and anonymous opt-out telemetry. The React UI supplies headless hooks plus optional branded chrome, voice, approvals, and connection surfaces.
- `packages/mcp/src/door.ts`
- `packages/vendo/src/cloud-tools.ts`
- `packages/vendo-telemetry/src/client.ts`

#### Reference hosts and validation ecosystem
Next.js accounting and banking demos are end-to-end reference integrations, each combining host APIs, local domain data, Vendo routes, React embedding, and optional Supabase/auth seams. An Express/Vite corpus host verifies framework portability. Corpus, fixtures, and benchmarks exercise conformance, installation, UI parity, security, and live-provider paths.
- `apps/demo-bank/src/app/api/vendo/[...vendo]/route.ts`
- `apps/demo-accounting/src/vendo/server.ts`
- `corpus/hosts/express-host/src/server/vendo.ts`

Main entry points: [`packages/guard/src/guard.ts`](https://github.com/runvendo/vendo/blob/main/packages/guard/src/guard.ts) (Guard), [`packages/agent/src/runner.ts`](https://github.com/runvendo/vendo/blob/main/packages/agent/src/runner.ts) (Agent runner), [`packages/apps/src/engine.ts`](https://github.com/runvendo/vendo/blob/main/packages/apps/src/engine.ts) (Apps engine), [`packages/actions/src/runtime/registry.ts`](https://github.com/runvendo/vendo/blob/main/packages/actions/src/runtime/registry.ts) (Tool registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_integration["Host Integration"]
  node_sdk["Vendo SDK / server<br/>composition entry<br/>[index.ts]"]
  node_cli["Vendo CLI<br/>host metadata sync<br/>[cli.ts]"]
  node_sync["API sync<br/>extraction pipeline<br/>[sync.ts]"]
  node_host_scan["Route scanner<br/>sync adapter<br/>[route-scan.ts]"]
end

subgraph group_generation["Generation &amp; UI"]
  node_core["Core contracts<br/>shared contracts<br/>[app-document.ts]"]
  node_compiler["UI v2 compiler<br/>tree compiler<br/>[compile.ts]"]
  node_ui["React tree renderer<br/>UI runtime<br/>[renderer-v2.tsx]"]
  node_jail["Jailed components<br/>iframe sandbox"]
end

subgraph group_execution["Guarded Execution"]
  node_registry["Tool registry<br/>action runtime<br/>[registry.ts]"]
  node_connectors["Connectors &amp; presets<br/>host adapters<br/>[mcp.ts]"]
  node_agent["Agent runner<br/>streaming orchestrator<br/>[runner.ts]"]
  node_threads["Conversation threads<br/>agent state<br/>[threads.ts]"]
  node_guard{{"Guard<br/>authorization choke point<br/>[guard.ts]"}}
  node_policy["Policy &amp; risk judge<br/>policy evaluator<br/>[judge.ts]"]
  node_apps["Apps engine<br/>app lifecycle<br/>[engine.ts]"]
  node_sandbox{{"App sandbox<br/>server-capable boundary<br/>[sandbox.ts]"}}
  node_automations["Automations engine<br/>trigger runner<br/>[engine.ts]"]
end

subgraph group_persistence["Persistence &amp; Surfaces"]
  node_store[("Tenant store<br/>durable storage<br/>[store.ts]")]
  node_mcp["MCP door<br/>external tool surface<br/>[door.ts]"]
  node_telemetry["Opt-out telemetry<br/>telemetry client<br/>[client.ts]"]
end

node_sdk -->|"composes runtime"| node_agent
node_sdk -->|"embeds UI"| node_ui
node_cli -->|"runs"| node_sync
node_sync -->|"uses adapter"| node_host_scan
node_sync -->|"extracts tools"| node_registry
node_core -->|"defines documents"| node_compiler
node_compiler -->|"compiled tree"| node_ui
node_ui -->|"renders untrusted components"| node_jail
node_connectors -->|"contributes tools"| node_registry
node_threads -->|"context"| node_agent
node_registry -->|"searchable tools"| node_agent
node_agent -->|"proposed actions"| node_guard
node_guard -->|"evaluates"| node_policy
node_policy -->|"decision / approval"| node_guard
node_guard -->|"authorized execution"| node_registry
node_agent -->|"generated app output"| node_apps
node_apps -->|"server-capable runs"| node_sandbox
node_automations -->|"triggered work"| node_guard
node_apps -->|"app-bound plans"| node_automations
node_agent -->|"threads and context"| node_store
node_guard -->|"grants and audit"| node_store
node_apps -->|"app records and versions"| node_store
node_mcp -->|"consented requests"| node_guard
node_sdk -.->|"optional events"| node_telemetry

click node_sdk "https://github.com/runvendo/vendo/blob/main/packages/vendo/src/index.ts"
click node_cli "https://github.com/runvendo/vendo/blob/main/packages/vendo/src/cli.ts"
click node_sync "https://github.com/runvendo/vendo/blob/main/packages/vendo/src/cli/sync.ts"
click node_host_scan "https://github.com/runvendo/vendo/blob/main/packages/actions/src/sync/route-scan.ts"
click node_core "https://github.com/runvendo/vendo/blob/main/packages/core/src/app-document.ts"
click node_compiler "https://github.com/runvendo/vendo/blob/main/packages/core/src/wire-v2/compile.ts"
click node_ui "https://github.com/runvendo/vendo/blob/main/packages/ui/src/tree/renderer-v2.tsx"
click node_jail "https://github.com/runvendo/vendo/blob/main/packages/ui/src/tree/jail/JailedComponent.tsx"
click node_registry "https://github.com/runvendo/vendo/blob/main/packages/actions/src/runtime/registry.ts"
click node_connectors "https://github.com/runvendo/vendo/blob/main/packages/actions/src/connectors/mcp.ts"
click node_agent "https://github.com/runvendo/vendo/blob/main/packages/agent/src/runner.ts"
click node_threads "https://github.com/runvendo/vendo/blob/main/packages/agent/src/threads.ts"
click node_guard "https://github.com/runvendo/vendo/blob/main/packages/guard/src/guard.ts"
click node_policy "https://github.com/runvendo/vendo/blob/main/packages/guard/src/judge.ts"
click node_apps "https://github.com/runvendo/vendo/blob/main/packages/apps/src/engine.ts"
click node_sandbox "https://github.com/runvendo/vendo/blob/main/packages/apps/src/sandbox.ts"
click node_automations "https://github.com/runvendo/vendo/blob/main/packages/automations/src/engine.ts"
click node_store "https://github.com/runvendo/vendo/blob/main/packages/store/src/store.ts"
click node_mcp "https://github.com/runvendo/vendo/blob/main/packages/mcp/src/door.ts"
click node_telemetry "https://github.com/runvendo/vendo/blob/main/packages/vendo-telemetry/src/client.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sdk,node_cli,node_sync,node_host_scan toneBlue
class node_core,node_compiler,node_ui,node_jail toneAmber
class node_registry,node_connectors,node_agent,node_threads,node_guard,node_policy,node_apps,node_sandbox,node_automations toneMint
class node_store,node_mcp,node_telemetry toneRose
```

## Components

### Host Integration

- [Vendo SDK / server](https://github.com/runvendo/vendo/blob/main/packages/vendo/src/index.ts): composition entry · Default host-facing composition API. · `packages/vendo/src/index.ts`
- [Vendo CLI](https://github.com/runvendo/vendo/blob/main/packages/vendo/src/cli.ts): host metadata sync · Initializes .vendo and proposes host wiring. · `packages/vendo/src/cli.ts`
- [API sync](https://github.com/runvendo/vendo/blob/main/packages/vendo/src/cli/sync.ts): extraction pipeline · Scans routes, schemas, themes, and host semantics. · `packages/vendo/src/cli/sync.ts`
- [Route scanner](https://github.com/runvendo/vendo/blob/main/packages/actions/src/sync/route-scan.ts): sync adapter · `packages/actions/src/sync/route-scan.ts`

### Generation & UI

- [Core contracts](https://github.com/runvendo/vendo/blob/main/packages/core/src/app-document.ts): shared contracts · Identity, grants, tools, app documents, and UI wire formats. · `packages/core/src/app-document.ts`
- [UI v2 compiler](https://github.com/runvendo/vendo/blob/main/packages/core/src/wire-v2/compile.ts): tree compiler · Compiles and validates structured generated UI. · `packages/core/src/wire-v2/compile.ts`
- [React tree renderer](https://github.com/runvendo/vendo/blob/main/packages/ui/src/tree/renderer-v2.tsx): UI runtime · Renders generated trees through registered components and bindings. · `packages/ui/src/tree/renderer-v2.tsx`
- [Jailed components](https://github.com/runvendo/vendo/blob/main/packages/ui/src/tree/jail/JailedComponent.tsx): iframe sandbox · Isolation boundary for untrusted generated components. · `packages/ui/src/tree/jail/JailedComponent.tsx`

### Guarded Execution

- [Tool registry](https://github.com/runvendo/vendo/blob/main/packages/actions/src/runtime/registry.ts): action runtime · Normalizes host APIs, connectors, and compound tools into searchable tools. · `packages/actions/src/runtime/registry.ts`
- [Connectors & presets](https://github.com/runvendo/vendo/blob/main/packages/actions/src/connectors/mcp.ts): host adapters · MCP connectors plus identity and execution-environment presets. · `packages/actions/src/connectors/mcp.ts`
- [Agent runner](https://github.com/runvendo/vendo/blob/main/packages/agent/src/runner.ts): streaming orchestrator · Packs context, streams models, selects tools, and iterates execution. · `packages/agent/src/runner.ts`
- [Conversation threads](https://github.com/runvendo/vendo/blob/main/packages/agent/src/threads.ts): agent state · `packages/agent/src/threads.ts`
- [Guard](https://github.com/runvendo/vendo/blob/main/packages/guard/src/guard.ts): authorization choke point · Separates model intent from approved execution and records outcomes. · `packages/guard/src/guard.ts`
- [Policy & risk judge](https://github.com/runvendo/vendo/blob/main/packages/guard/src/judge.ts): policy evaluator · Evaluates risk, grants, approvals, and breakers. · `packages/guard/src/judge.ts`
- [Apps engine](https://github.com/runvendo/vendo/blob/main/packages/apps/src/engine.ts): app lifecycle · Versions generated apps and manages generation, edit, run, and ship lifecycles. · `packages/apps/src/engine.ts`
- [App sandbox](https://github.com/runvendo/vendo/blob/main/packages/apps/src/sandbox.ts): server-capable boundary · Escalation boundary for generated server behavior. · `packages/apps/src/sandbox.ts`
- [Automations engine](https://github.com/runvendo/vendo/blob/main/packages/automations/src/engine.ts): trigger runner · Runs schedules, host events, and external triggers through Guard. · `packages/automations/src/engine.ts`

### Persistence & Surfaces

- [Tenant store](https://github.com/runvendo/vendo/blob/main/packages/store/src/store.ts): durable storage · Isolated persistence for principals, threads, grants, apps, audit, blobs, and secrets. · `packages/store/src/store.ts`
- [MCP door](https://github.com/runvendo/vendo/blob/main/packages/mcp/src/door.ts): external tool surface · OAuth- and consent-gated MCP exposure. · `packages/mcp/src/door.ts`
- [Opt-out telemetry](https://github.com/runvendo/vendo/blob/main/packages/vendo-telemetry/src/client.ts): telemetry client · `packages/vendo-telemetry/src/client.ts`

## Connections

- Vendo SDK / server → Agent runner: composes runtime
- Vendo SDK / server → React tree renderer: embeds UI
- Vendo CLI → API sync: runs
- API sync → Route scanner: uses adapter
- API sync → Tool registry: extracts tools
- Core contracts → UI v2 compiler: defines documents
- UI v2 compiler → React tree renderer: compiled tree
- React tree renderer → Jailed components: renders untrusted components
- Connectors & presets → Tool registry: contributes tools
- Conversation threads → Agent runner: context
- Tool registry → Agent runner: searchable tools
- Agent runner → Guard: proposed actions
- Guard → Policy & risk judge: evaluates
- Policy & risk judge → Guard: decision / approval
- Guard → Tool registry: authorized execution
- Agent runner → Apps engine: generated app output
- Apps engine → App sandbox: server-capable runs
- Automations engine → Guard: triggered work
- Apps engine → Automations engine: app-bound plans
- Agent runner → Tenant store: threads and context
- Guard → Tenant store: grants and audit
- Apps engine → Tenant store: app records and versions
- MCP door → Guard: consented requests
- Vendo SDK / server → Opt-out telemetry: optional events
