> ## Documentation Index
> Fetch the complete documentation index at: https://docs.agentfront.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Installation

> How to install Enclave libraries

# Installation

Each library in the Enclave monorepo can be installed independently.

## Prerequisites

* **Node.js**: >= 22.0.0
* **npm**: >= 10 (or yarn/pnpm equivalent)

## Core Libraries

### @enclave-vm/core

Secure AgentScript execution environment with defense-in-depth.

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
npm install @enclave-vm/core
```

### @enclave-vm/ast

AST-based JavaScript validator: the static layer in front of the sandbox.

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
npm install @enclave-vm/ast
```

## EnclaveJS Streaming Runtime

The EnclaveJS packages provide a streaming runtime for real-time code execution with tool orchestration.

### Full Stack (Recommended)

Install all packages needed for a complete streaming setup:

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
# Server-side
npm install @enclave-vm/broker

# Client-side
npm install @enclave-vm/client @enclave-vm/react
```

### Individual Packages

#### @enclave-vm/types

Protocol types and Zod schemas (automatically installed as dependency).

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
npm install @enclave-vm/types
```

#### @enclave-vm/stream

NDJSON parsing and reconnection helpers. It also exports encryption primitives, which the client and the broker do not use.

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
npm install @enclave-vm/stream
```

#### @enclave-vm/broker

Tool broker with session management and HTTP API. It does not authenticate callers: put your own authentication in front of its routes. Authentication alone does not keep the sessions of one caller from another: a broker that serves more than one caller also needs the `identify` hook of its session handler (see [Who may see a session](https://docs.agentfront.dev/enclave/enclavejs/broker.md#who-may-see-a-session)).

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
npm install @enclave-vm/broker
```

#### @enclave-vm/client

Browser and Node.js client SDK. Requests and events are plain JSON over HTTP: use an `https:` base URL.

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
npm install @enclave-vm/client
```

#### @enclave-vm/react

React hooks and components.

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
npm install @enclave-vm/react
```

**Peer dependency:** React >= 18.0.0

#### @enclave-vm/runtime

Building blocks of a runtime worker (session bookkeeping and channels). It is not a runnable service and does not execute scripts yet: an `execute` request ends with `RuntimeNotImplementedError`. To run scripts, use `@enclave-vm/broker` or `@enclave-vm/core`.

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
npm install @enclave-vm/runtime
```

## Quick Start Examples

### Basic Sandbox (@enclave-vm/core)

```typescript theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
import { Enclave } from '@enclave-vm/core';

const enclave = new Enclave({ securityLevel: 'SECURE' });
const result = await enclave.run('return 1 + 1');
console.log(result.value); // 2
```

### Streaming with React

```tsx theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
import { EnclaveProvider, useEnclaveSession } from '@enclave-vm/react';

function App() {
  return (
    <EnclaveProvider config={{ baseUrl: 'http://localhost:3000' }}>
      <CodeRunner />
    </EnclaveProvider>
  );
}

function CodeRunner() {
  const { execute, isRunning, result } = useEnclaveSession();

  return (
    <div>
      <button onClick={() => execute('return 1 + 1')} disabled={isRunning}>
        Run
      </button>
      {result?.success && <pre>{JSON.stringify(result.value)}</pre>}
    </div>
  );
}
```

## Development Setup

To work on the Enclave monorepo itself:

```bash theme={"theme":{"light":"snazzy-light","dark":"dark-plus"}}
# Clone the repository
git clone https://github.com/agentfront/enclave.git
cd enclave

# Install dependencies
yarn install

# Build all libraries
yarn build

# Run tests
yarn test
```

## Package Versions

| Package | Version | Description |
| - | - | - |
| @enclave-vm/core | 2.19.1 | Secure sandbox runtime |
| @enclave-vm/ast | 2.19.1 | AST security validator |
| @enclave-vm/browser | 2.19.1 | Sandbox for browsers |
| @enclave-vm/types | 2.19.1 | Protocol types |
| @enclave-vm/stream | 2.19.1 | Streaming protocol helpers |
| @enclave-vm/broker | 2.19.1 | Tool broker |
| @enclave-vm/client | 2.19.1 | Client SDK |
| @enclave-vm/react | 2.19.1 | React integration |
| @enclave-vm/runtime | 2.19.1 | Runtime worker building blocks (does not execute yet) |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.