HazelJS Installation
Install HazelJS for Agent OS (Meridian / hazel agent) or a framework HTTP app. This page covers prerequisites, packages, and troubleshooting.
Quick Reference
- Purpose: Install HazelJS and start an Agent OS or HTTP project.
- When to use: First install, adding packages, or troubleshooting.
- Key concepts: Primary path is Meridian.
@hazeljs/core(HTTP/DI),@hazeljs/agent(Agent OS kernel),@hazeljs/cli(hazel agent new). Optional: Skillgate, Gatekeeper, Agent VM, RAG, HCEL. - Inputs: Node.js 18+, npm 9+.
- Outputs: Meridian or a running app on
http://localhost:3000. - Dependencies: Node.js 18+, TypeScript.
@hazeljs/coreloadsreflect-metadata— do not install or import it.class-validator/class-transformeronly if you use DTO validation. - Common patterns: Clone Meridian →
store:sync→platform:sync→dev; orhazel agent new my-desk --template=agent-os; ornpm install @hazeljs/corefor a one-file API. - Common mistakes: Treating
--template=ai-nativeas the Agent OS flagship; missingexperimentalDecoratorsin tsconfig; installing or importingreflect-metadatain application code.
HazelJS Prerequisites
- Node.js — Version 18.x or later (
node --version). Recommended: Node.js 20 LTS. - npm — Version 9.x or later (
npm --version) - Git — Optional, for development (
git --version)
HazelJS Installation Methods
Agent OS — Meridian (recommended)
git clone https://github.com/hazel-js/hazeljs-meridian-ops.git
cd hazeljs-meridian-ops
npm install
npm run store:sync
npm run platform:sync
npm run dev
Agent OS scaffold
npm install -g @hazeljs/cli
hazel agent new my-desk --template=agent-os
cd my-desk && npm install && npm run dev
Framework HTTP app (secondary)
# Install the HazelJS CLI globally
npm install -g @hazeljs/cli
# Skeleton API
hazel g app my-app
cd my-app
npm install
npm run dev
Or create a new HazelJS app with interactive prompts:
hazel new my-app -i
--template=ai-native scaffolds HCEL / RAG / Docker. It is not the Agent OS flagship (use Meridian for DNA / Store / Skillgate / HITL).
Install HazelJS Core in an Existing Project
npm install @hazeljs/core
Install Specific HazelJS Packages
# Example: install core + AI + auth
npm install @hazeljs/core @hazeljs/ai @hazeljs/auth
# Example: install core + caching + database
npm install @hazeljs/core @hazeljs/cache @hazeljs/prisma
HazelJS Package Decision Guide
Use this table when you know the goal but not the package name. Each row includes @hazeljs/core where it is required. Full list: Available Packages below.
| I want to... | Install |
|---|---|
| Run the Agent OS teaching app | Clone Meridian |
| Scaffold DNA / HITL / Skillgate | hazel agent new + @hazeljs/agent |
| Build a basic HTTP API | @hazeljs/core |
| Scaffold projects from the CLI | @hazeljs/cli |
| Add LLM integration (OpenAI, Anthropic, etc.) | @hazeljs/core @hazeljs/ai |
| Build AI agents with tools | @hazeljs/core @hazeljs/ai @hazeljs/agent |
| Reversible tools + speculative branches | @hazeljs/agent-vm @hazeljs/agent |
| Curate OpenAPI / REST → agent skills | @hazeljs/skillgate @hazeljs/agent (+ @hazeljs/swagger for fromModule) |
| Authorize every tool call (fail-closed) | @hazeljs/agent-gatekeeper (+ @hazeljs/agent) |
| Add RAG / semantic search over documents | @hazeljs/core @hazeljs/ai @hazeljs/rag |
Regression-test agents with describeAgent | @hazeljs/testing @hazeljs/eval (+ @hazeljs/agent) |
| Benchmark agent quality across commits | @hazeljs/benchmark (+ @hazeljs/agent / your scorer) |
| Full Agent OS lifecycle (policies, DNA, twin, Skillgate, Gatekeeper) | See Agent OS guide |
| Build agents and RAG with shared conversation memory | @hazeljs/core @hazeljs/ai @hazeljs/agent @hazeljs/rag (+ optional @hazeljs/memory) |
| Versioned prompt templates (not inline strings) | @hazeljs/core @hazeljs/prompts (+ @hazeljs/ai when calling LLMs) |
| Persistent memory store (Redis/Prisma) for agents or RAG | @hazeljs/core @hazeljs/memory |
| Block PII / prompt injection / unsafe LLM output | @hazeljs/core @hazeljs/guardrails (+ @hazeljs/ai) |
| Regression-test RAG or agents (golden datasets, CI) | @hazeljs/core @hazeljs/eval (+ @hazeljs/rag or @hazeljs/agent; prefer @hazeljs/testing for agent suites) |
| Trace LLM calls and agent steps (OpenTelemetry) | @hazeljs/core @hazeljs/observability (+ @hazeljs/ai / @hazeljs/agent) |
| Connect to MCP tool servers | @hazeljs/core @hazeljs/mcp (+ @hazeljs/ai / @hazeljs/agent) |
| ML models, feature store, batch inference | @hazeljs/core @hazeljs/ml (+ optional @hazeljs/data) |
| Add authentication (JWT) | @hazeljs/core @hazeljs/auth |
| Add OAuth social login | @hazeljs/core @hazeljs/auth @hazeljs/oauth |
| Fine-grained authorization (roles/abilities) | @hazeljs/core @hazeljs/casl (+ @hazeljs/auth) |
| Audit log who did what | @hazeljs/core @hazeljs/audit |
| Add database (Prisma) | @hazeljs/core @hazeljs/prisma |
| Add database (TypeORM) | @hazeljs/core @hazeljs/typeorm |
| Add caching (Redis/memory) | @hazeljs/core @hazeljs/cache |
Type-safe config / .env | @hazeljs/core @hazeljs/config |
| Shared Git-backed config (Spring Cloud Config style) | @hazeljs/core @hazeljs/config-server |
| Background jobs with Redis (BullMQ) | @hazeljs/core @hazeljs/queue |
| CPU-intensive work off the main thread | @hazeljs/core @hazeljs/worker |
| Scheduled recurring tasks (cron expressions) | @hazeljs/core @hazeljs/cron |
| Durable workflows (wait/resume, idempotency) | @hazeljs/core @hazeljs/flow |
| Run flows as a standalone HTTP service | @hazeljs/core @hazeljs/flow-runtime |
| Event streaming between microservices (Kafka) | @hazeljs/core @hazeljs/kafka |
| Google Cloud Pub/Sub messaging | @hazeljs/core @hazeljs/pubsub |
| WhatsApp / Telegram / Viber bots | @hazeljs/core @hazeljs/messaging (+ @hazeljs/ai) |
| In-process pub/sub between modules | @hazeljs/core @hazeljs/event-emitter |
| Distributed saga / compensation across services | @hazeljs/core @hazeljs/saga |
| Distributed lock (only one instance runs a job) | @hazeljs/core @hazeljs/distributed-lock |
| Service discovery for microservices | @hazeljs/core @hazeljs/discovery |
| API gateway (versioning, canary routing) | @hazeljs/core @hazeljs/gateway |
| Circuit breaker, retry, rate limit | @hazeljs/core @hazeljs/resilience |
| Self-heal failing methods / pods (K8s restart, HPA boost) | @hazeljs/core @hazeljs/self-healing (+ optional @hazeljs/ai @hazeljs/ops-agent @hazeljs/resilience) |
| Predict traffic and raise HPA before spikes | @hazeljs/core @hazeljs/predictive-scaling (+ optional @hazeljs/self-healing) |
| Real-time WebSocket / SSE | @hazeljs/core @hazeljs/websocket |
| Realtime subscriptions (higher-level than raw WS) | @hazeljs/core @hazeljs/realtime |
| GraphQL API | @hazeljs/core @hazeljs/graphql |
| gRPC services | @hazeljs/core @hazeljs/grpc |
| OpenAPI / Swagger docs | @hazeljs/core @hazeljs/swagger |
| ETL / data pipelines | @hazeljs/core @hazeljs/data |
| Feature flags | @hazeljs/core @hazeljs/feature-toggle |
| i18n / translations | @hazeljs/core @hazeljs/i18n |
| Inspect routes, cron, agents at runtime | @hazeljs/core @hazeljs/inspector |
| Deploy serverless (AWS Lambda) | @hazeljs/core @hazeljs/serverless |
| Ops/incident triage (Jira, Slack) | @hazeljs/core @hazeljs/ops-agent (+ @hazeljs/agent @hazeljs/ai) |
| PDF documents to audio (TTS) | @hazeljs/core @hazeljs/pdf-to-audio (+ @hazeljs/ai) |
| End-to-end support chat + RAG example | See Support Agent (uses core, rag, ai, memory patterns) |
Similar packages — quick picks: Queue vs Worker vs Cron · Flow vs Flow Runtime · Kafka vs Pub/Sub vs Messaging · RAG vs Agentic RAG · Memory in RAG vs @hazeljs/memory
Available Packages
55 packages from public/api/packages-index.json — updated when new packages ship. See Recipes for copy-paste install examples per package.
Core
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/core | The foundation of HazelJS — DI, routing, and decorators (required for every HazelJS app) |
AI & Machine Learning
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/ai | AI integration — OpenAI, Anthropic, Gemini, Cohere, Ollama | |
| @hazeljs/agent | Agent OS kernel — durable AgentRun, HITL, leases, tools, memory, loops, policies, DNA, and human-in-the-loop | |
| @hazeljs/agent-gatekeeper | Runtime authorization and policy enforcement for every agent tool call — default deny, Kafka/OTEL audit, Redis approvals, rewrite | |
| @hazeljs/skillgate | Curate OpenAPI / Hazel REST endpoints into governed agent skills with HITL defaults and optional MCP export | |
| @hazeljs/rag | Retrieval-Augmented Generation and vector search | |
| @hazeljs/ml | Machine Learning and model management | |
| @hazeljs/prompts | Prompt template management and versioning | |
| @hazeljs/memory | Persistent memory for AI agents and conversations | |
| @hazeljs/guardrails | Content safety — PII redaction, prompt injection detection, output validation | |
| @hazeljs/ops-agent | Ops agent for Jira, Slack, DevOps — AI-powered incident triage | |
| @hazeljs/eval | Golden datasets, IR/RAG metrics, agent trajectory scoring, and CI eval reporting | |
| @hazeljs/testing | Agent OS testing DSL — describeAgent suites, assertions, and CI helpers on @hazeljs/eval |
Security & Authentication
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/auth | Authentication and JWT | |
| @hazeljs/oauth | OAuth 2.0 social login — Google, Microsoft, GitHub, Facebook, Twitter | |
| @hazeljs/casl | Authorization with CASL | |
| @hazeljs/audit | Audit logging and compliance |
Infrastructure
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/cache | Caching — Memory, Redis, CDN | |
| @hazeljs/config | Type-safe configuration management | |
| @hazeljs/config-server | Git-backed distributed configuration server — Spring Cloud Config for TypeScript | |
| @hazeljs/cron | Cron job scheduling with decorators | |
| @hazeljs/queue | Redis-backed job queue (BullMQ) | |
| @hazeljs/worker | CPU-intensive task offloading via worker threads | |
| @hazeljs/flow | Durable execution graph engine — workflows with wait/resume, idempotency | |
| @hazeljs/flow-runtime | Standalone HTTP service for flow — start/tick/resume runs via REST API |
Database
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/prisma | Prisma ORM integration | |
| @hazeljs/typeorm | TypeORM integration |
Data Processing
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/data | Data processing and ETL pipelines |
API
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/graphql | GraphQL server and client with decorators | |
| @hazeljs/grpc | gRPC server and client with decorators | |
| @hazeljs/swagger | Swagger/OpenAPI documentation |
Real-Time
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/websocket | WebSocket and Server-Sent Events | |
| @hazeljs/realtime | Real-time communication and pub/sub |
Messaging & Events
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/kafka | Kafka — produce, consume, and stream processing | |
| @hazeljs/messaging | Multichannel messaging — WhatsApp, Telegram, Viber with LLM-powered bots | |
| @hazeljs/event-emitter | Event-driven architecture with decorators | |
| @hazeljs/pubsub | Google Cloud Pub/Sub — typed publishing and decorator-based consumers |
Microservices
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/discovery | Service discovery and registry for microservices | |
| @hazeljs/gateway | API gateway — version routing, canary deployments | |
| @hazeljs/resilience | Circuit breaker, retry, rate limit, bulkhead, timeout | |
| @hazeljs/self-healing | Self-healing microservices — diagnosis, rollback, pod restart, HPA boost | |
| @hazeljs/predictive-scaling | Predictive auto-scaling — traffic forecasts and proactive Kubernetes HPA | |
| @hazeljs/saga | Distributed transactions — orchestration and choreography with compensation | |
| @hazeljs/distributed-lock | Distributed locking — Redis or in-memory mutual exclusion across instances |
Deployment
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/serverless | Serverless adapters — AWS Lambda, Google Cloud Functions |
Tooling
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/cli | CLI for scaffolding and generating HazelJS applications | |
| @hazeljs/inspector | Framework-aware runtime inspector — routes, cron, agents, flows, Agent OS SSE timelines | |
| @hazeljs/observability | OpenTelemetry tracing, LLM cost tracking, and agent span instrumentation |
Utilities
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/i18n | Internationalization and localization | |
| @hazeljs/feature-toggle | Feature flags and toggles |
Integrations
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/payment | Payment processing integrations | |
| @hazeljs/pdf-to-audio | Convert PDF documents to audio using TTS | |
| @hazeljs/mcp | Model Context Protocol integration |
Other
| Package | npm downloads | Description |
|---|---|---|
| @hazeljs/agent-vm | Effect-typed agent execution — transactional undo, reversible tools, speculative multi-branch execution with automatic rollback | |
| @hazeljs/benchmark | Agent OS benchmark helpers — run, summarize, and compare agent golden runs across commits |
Install any package with npm:
npm install @hazeljs/core @hazeljs/ai
Browse full documentation from the docs sidebar or each package page linked in the table above.
Building HazelJS from Source
Build HazelJS from source if you want to contribute, customize, or use the latest development version.
# Step 1: Clone the repository
git clone https://github.com/hazel-js/hazeljs.git
# Step 2: Navigate to the project directory
cd hazeljs
# Step 3: Install dependencies
npm install
# Step 4: Build the project
npm run build
# Step 5: Link the CLI (optional)
npm link
Verifying HazelJS Installation
After installation, verify that HazelJS is installed correctly:
# Check CLI version
hazel --version
# Should display your installed CLI version
# Check available commands
hazel --help
Creating Your First HazelJS Project
Agent OS: clone Meridian or hazel agent new my-desk --template=agent-os.
HTTP skeleton:
hazel new my-app -i
cd my-app
npm run dev
Manual HazelJS Project Setup
If you prefer to set up manually without the HazelJS CLI:
1. Initialize a new project:
mkdir my-app && cd my-app
npm init -y
npm install @hazeljs/core class-validator class-transformer
npm install -D typescript @types/node ts-node-dev
2. Create tsconfig.json:
{
"compilerOptions": {
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2020"],
"declaration": true,
"outDir": "./dist",
"rootDir": "./src",
"strict": true,
"esModuleInterop": true,
"skipLibCheck": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"resolveJsonModule": true,
"moduleResolution": "node"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
Important:
experimentalDecoratorsmust betrue.emitDecoratorMetadatais optional for most apps. Do not install or importreflect-metadata;@hazeljs/coreloads it automatically.
3. Create src/main.ts:
import { HazelApp, HazelModule, Controller, Get } from '@hazeljs/core';
@Controller('hello')
class HelloController {
@Get()
hello() {
return { message: 'Hello, World!' };
}
}
@HazelModule({
controllers: [HelloController],
})
class AppModule {}
async function bootstrap() {
const app = new HazelApp(AppModule);
await app.listen(3000);
console.log('Application is running on http://localhost:3000');
}
bootstrap();
4. Add scripts to package.json:
{
"scripts": {
"dev": "ts-node-dev --respawn src/main.ts",
"build": "tsc",
"start": "node dist/main.js"
}
}
5. Run:
npm run dev
Visit http://localhost:3000/hello — you should see {"message":"Hello, World!"}.
HazelJS Environment Variables
Create a .env file in your HazelJS project root:
PORT=3000
NODE_ENV=development
DATABASE_URL=postgresql://user:password@localhost:5432/mydb
JWT_SECRET=your-secret-key
HazelJS Project Structure
A typical HazelJS project follows this structure:
my-app/
├── src/
│ ├── user/
│ │ ├── dto/
│ │ │ └── create-user.dto.ts
│ │ ├── user.controller.ts
│ │ ├── user.service.ts
│ │ └── user.module.ts
│ ├── app.module.ts
│ └── main.ts
├── .env
├── package.json
└── tsconfig.json
HazelJS Installation Troubleshooting
Permission Errors (npm install -g)
If you encounter permission errors when installing globally:
sudo npm install -g @hazeljs/cli
Or configure npm to use a different directory for global packages.
Command Not Found
If the hazel command is not found:
- Verify npm global bin directory is in your PATH
- Restart your terminal after installation
- Check installation with:
npm list -g @hazeljs/cli
Version Conflicts
If you have multiple Node.js versions installed:
nvm use 20
Use nvm or n to manage Node.js versions.
Decorators Not Working
Ensure experimentalDecorators is true in your tsconfig.json. You do not need to install or import reflect-metadata — @hazeljs/core already does that.
Validation Not Working
Install the required peer dependencies:
npm install class-validator class-transformer
Use @Body(DtoClass) decorator with your DTO class for automatic validation.
Related Pages
- Introduction — Agent OS overview
- Agent OS guide — DNA, HITL, Skillgate, local apply
- CLI —
hazel agent newand generators - Core Package — HTTP / DI pipeline
- Concepts & Glossary — Decorators and terms
Next Concepts to Learn
- Meridian — Flagship teaching app
- Agent Package — Kernel APIs
- Skillgate — OpenAPI → skills
- Testing Package —
describeAgentCI - Controllers Guide — REST beside agents