@agenticmail/enterprise 0.2.2 → 0.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +26 -0
- package/README.md +939 -0
- package/dashboards/dotnet/Program.cs +5 -5
- package/dashboards/express/app.js +5 -5
- package/dashboards/go/main.go +8 -8
- package/dashboards/html/index.html +41 -18
- package/dashboards/java/AgenticMailDashboard.java +5 -5
- package/dashboards/php/index.php +8 -8
- package/dashboards/python/app.py +8 -8
- package/dashboards/ruby/app.rb +7 -7
- package/dashboards/shared-styles.css +57 -0
- package/dist/chunk-BE7MXVLA.js +757 -0
- package/dist/chunk-BS2WCSHO.js +48 -0
- package/dist/chunk-FL3VQBGL.js +757 -0
- package/dist/chunk-GXIEEA2T.js +48 -0
- package/dist/chunk-JLSQOQ5L.js +255 -0
- package/dist/chunk-TVF23PUW.js +338 -0
- package/dist/cli.js +305 -140
- package/dist/dashboard/index.html +833 -510
- package/dist/factory-HINWFYZ3.js +9 -0
- package/dist/factory-V37IG5AT.js +9 -0
- package/dist/index.js +18 -12
- package/dist/managed-RZITNPXG.js +14 -0
- package/dist/server-32YYCI3A.js +8 -0
- package/dist/server-H3C6WUOS.js +8 -0
- package/dist/sqlite-VLKVAJA4.js +442 -0
- package/package.json +28 -3
- package/src/cli.ts +15 -251
- package/src/dashboard/index.html +833 -510
- package/src/db/sqlite.ts +4 -1
- package/src/server.ts +1 -1
- package/src/setup/company.ts +64 -0
- package/src/setup/database.ts +119 -0
- package/src/setup/deployment.ts +50 -0
- package/src/setup/domain.ts +46 -0
- package/src/setup/index.ts +82 -0
- package/src/setup/provision.ts +226 -0
- package/test-integration.mjs +383 -0
- package/agenticmail-enterprise.db +0 -0
package/README.md
ADDED
|
@@ -0,0 +1,939 @@
|
|
|
1
|
+
# @agenticmail/enterprise
|
|
2
|
+
|
|
3
|
+
**Deploy and manage AI agents as employees in your organization.** Full platform for configuring agent skills, permissions, deployment targets, lifecycle management, and compliance — with a web dashboard and REST API.
|
|
4
|
+
|
|
5
|
+
AgenticMail Enterprise turns AI agents into managed employees. You define what an agent can do (skills, tools, permissions), where it runs (Docker, VPS, Fly.io, Railway), and how it's supervised (approval workflows, activity tracking, audit logs). The platform handles provisioning, health monitoring, auto-recovery, and multi-tenant isolation. Each agent gets its own email, workspace, and tool access — governed by policies you control from a single dashboard.
|
|
6
|
+
|
|
7
|
+
[](https://www.npmjs.com/package/@agenticmail/enterprise)
|
|
8
|
+
[](./LICENSE)
|
|
9
|
+
[](https://nodejs.org)
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Table of Contents
|
|
14
|
+
|
|
15
|
+
- [Quick Start](#quick-start)
|
|
16
|
+
- [What This Does (Plain English)](#what-this-does-plain-english)
|
|
17
|
+
- [Architecture](#architecture)
|
|
18
|
+
- [Setup Wizard](#setup-wizard)
|
|
19
|
+
- [Database Support](#database-support)
|
|
20
|
+
- [The Engine](#the-engine)
|
|
21
|
+
- [Skills & Permissions](#1-skills--permissions)
|
|
22
|
+
- [Agent Configuration](#2-agent-configuration)
|
|
23
|
+
- [Deployment Engine](#3-deployment-engine)
|
|
24
|
+
- [Approval Workflows](#4-approval-workflows)
|
|
25
|
+
- [Agent Lifecycle](#5-agent-lifecycle)
|
|
26
|
+
- [Knowledge Base](#6-knowledge-base)
|
|
27
|
+
- [Multi-Tenant Isolation](#7-multi-tenant-isolation)
|
|
28
|
+
- [Activity Tracking](#8-activity-tracking)
|
|
29
|
+
- [Tool Catalog](#9-tool-catalog)
|
|
30
|
+
- [OpenClaw Hook](#10-openclaw-hook)
|
|
31
|
+
- [AgenticMail Bridge](#11-agenticmail-bridge)
|
|
32
|
+
- [REST API](#rest-api)
|
|
33
|
+
- [Authentication](#authentication)
|
|
34
|
+
- [Admin Endpoints](#admin-endpoints)
|
|
35
|
+
- [Engine Endpoints](#engine-endpoints)
|
|
36
|
+
- [Dashboard](#dashboard)
|
|
37
|
+
- [Deployment](#deployment)
|
|
38
|
+
- [AgenticMail Cloud](#agenticmail-cloud)
|
|
39
|
+
- [Fly.io](#flyio)
|
|
40
|
+
- [Docker](#docker)
|
|
41
|
+
- [Local Development](#local-development)
|
|
42
|
+
- [Server Configuration](#server-configuration)
|
|
43
|
+
- [Middleware](#middleware)
|
|
44
|
+
- [Resilience](#resilience)
|
|
45
|
+
- [Programmatic Usage](#programmatic-usage)
|
|
46
|
+
- [Security](#security)
|
|
47
|
+
- [License](#license)
|
|
48
|
+
|
|
49
|
+
---
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
```bash
|
|
54
|
+
npx @agenticmail/enterprise
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
The interactive wizard walks you through:
|
|
58
|
+
1. Company name and admin credentials
|
|
59
|
+
2. Database selection (10 backends supported)
|
|
60
|
+
3. Deployment target (Cloud, Fly.io, Docker, Railway, or Local)
|
|
61
|
+
4. Optional custom domain
|
|
62
|
+
|
|
63
|
+
Within 2 minutes you get a live dashboard URL with your admin account ready.
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## What This Does (Plain English)
|
|
68
|
+
|
|
69
|
+
Think of AgenticMail Enterprise as an HR department for AI agents.
|
|
70
|
+
|
|
71
|
+
**The problem:** You want to deploy AI agents that do real work — answer customer emails, research topics, write reports, manage schedules. But right now, setting up each agent means manually configuring tools, permissions, credentials, deployment, and monitoring. Scale that to 10 or 50 agents across a team, and it becomes unmanageable.
|
|
72
|
+
|
|
73
|
+
**What Enterprise does:**
|
|
74
|
+
|
|
75
|
+
- **Hiring** — You pick from 38 pre-built skill sets (email management, web research, coding, customer support, etc.) and assign them to a new agent. The platform generates all the config files, workspace setup, and tool permissions automatically.
|
|
76
|
+
|
|
77
|
+
- **Onboarding** — The agent gets deployed to your chosen infrastructure (a Docker container, a VPS, Fly.io, Railway, or our managed cloud). It gets its own email address, API keys, and workspace. No manual setup.
|
|
78
|
+
|
|
79
|
+
- **Permissions** — You control exactly what each agent can and can't do. "This agent can send emails but not access the filesystem." "This agent can browse the web but needs approval before making purchases." Five preset permission profiles (Research Assistant, Customer Support, Developer, Full Access, Sandbox) or fully custom.
|
|
80
|
+
|
|
81
|
+
- **Supervision** — Sensitive actions trigger approval workflows. An agent wants to send an email to a client? It gets queued for human review first. You set the policies.
|
|
82
|
+
|
|
83
|
+
- **Health & Recovery** — The platform monitors every agent. If one crashes, it auto-restarts. If it's stuck, it gets flagged. You see everything in the dashboard — which agents are running, what they're doing, how much they cost.
|
|
84
|
+
|
|
85
|
+
- **Knowledge** — Agents can share knowledge bases. Upload documents, and the platform chunks them for retrieval. Agents search the knowledge base as part of their workflow.
|
|
86
|
+
|
|
87
|
+
- **Teams** — Multi-tenant isolation means different teams or clients get their own agents, data, and billing. Plan tiers (Free, Team, Enterprise, Self-Hosted) enforce limits.
|
|
88
|
+
|
|
89
|
+
- **Audit** — Every action is logged. Who did what, when, to which resource. Compliance teams can pull reports.
|
|
90
|
+
|
|
91
|
+
**In short:** You focus on what your agents should do. Enterprise handles how they run, where they run, and keeping them in line.
|
|
92
|
+
|
|
93
|
+
---
|
|
94
|
+
|
|
95
|
+
## Architecture
|
|
96
|
+
|
|
97
|
+
```
|
|
98
|
+
┌──────────────────────────────────────────────────────┐
|
|
99
|
+
│ Dashboard (Web UI) │
|
|
100
|
+
│ Single HTML · React 18 · CDN │
|
|
101
|
+
└─────────────────────────┬────────────────────────────┘
|
|
102
|
+
│ HTTP
|
|
103
|
+
┌─────────────────────────▼────────────────────────────┐
|
|
104
|
+
│ Hono API Server │
|
|
105
|
+
│ │
|
|
106
|
+
│ ┌─────────┐ ┌──────────┐ ┌──────────────────────┐ │
|
|
107
|
+
│ │ Auth │ │ Admin │ │ Engine │ │
|
|
108
|
+
│ │ Routes │ │ Routes │ │ │ │
|
|
109
|
+
│ │ │ │ │ │ Skills · Permissions │ │
|
|
110
|
+
│ │ JWT │ │ Users │ │ Config · Deployer │ │
|
|
111
|
+
│ │ Login │ │ Agents │ │ Approvals · Lifecycle│ │
|
|
112
|
+
│ │ Keys │ │ Audit │ │ Knowledge · Tenants │ │
|
|
113
|
+
│ │ │ │ Keys │ │ Activity · Hook │ │
|
|
114
|
+
│ └─────────┘ └──────────┘ └──────────────────────┘ │
|
|
115
|
+
│ │
|
|
116
|
+
│ ┌─────────────────────────────────────────────────┐ │
|
|
117
|
+
│ │ Middleware Stack │ │
|
|
118
|
+
│ │ Rate Limit · CORS · Security Headers · Audit │ │
|
|
119
|
+
│ │ Request ID · Error Handler · RBAC │ │
|
|
120
|
+
│ └─────────────────────────────────────────────────┘ │
|
|
121
|
+
│ │
|
|
122
|
+
│ ┌─────────────────────────────────────────────────┐ │
|
|
123
|
+
│ │ Resilience Layer │ │
|
|
124
|
+
│ │ Circuit Breaker · Health Monitor · Retry │ │
|
|
125
|
+
│ │ Rate Limiter · Keyed Rate Limiter │ │
|
|
126
|
+
│ └─────────────────────────────────────────────────┘ │
|
|
127
|
+
└─────────────────────────┬────────────────────────────┘
|
|
128
|
+
│
|
|
129
|
+
┌─────────────────────────▼────────────────────────────┐
|
|
130
|
+
│ Database Adapter (Abstract) │
|
|
131
|
+
│ │
|
|
132
|
+
│ SQLite · Postgres · MySQL · MongoDB · DynamoDB │
|
|
133
|
+
│ Turso · Supabase · Neon · PlanetScale · CockroachDB │
|
|
134
|
+
└──────────────────────────────────────────────────────┘
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
---
|
|
138
|
+
|
|
139
|
+
## Setup Wizard
|
|
140
|
+
|
|
141
|
+
The CLI wizard (`npx @agenticmail/enterprise`) runs in 4 steps:
|
|
142
|
+
|
|
143
|
+
### Step 1: Company Info
|
|
144
|
+
- Company name (used to generate your subdomain)
|
|
145
|
+
- Admin email and password
|
|
146
|
+
|
|
147
|
+
### Step 2: Database
|
|
148
|
+
Choose from 10 supported backends. Each asks for its specific connection details:
|
|
149
|
+
- **SQLite** — file path (default: `./agenticmail-enterprise.db`)
|
|
150
|
+
- **PostgreSQL / Supabase / Neon / CockroachDB** — connection string
|
|
151
|
+
- **MySQL / PlanetScale** — connection string
|
|
152
|
+
- **MongoDB** — connection URI
|
|
153
|
+
- **DynamoDB** — AWS region + credentials
|
|
154
|
+
- **Turso / LibSQL** — database URL + auth token
|
|
155
|
+
|
|
156
|
+
### Step 3: Deployment Target
|
|
157
|
+
- **AgenticMail Cloud** — managed hosting, instant URL (`company.agenticmail.cloud`)
|
|
158
|
+
- **Fly.io** — generates `fly.toml`, you deploy to your Fly account
|
|
159
|
+
- **Railway** — generates Railway config
|
|
160
|
+
- **Docker** — generates `docker-compose.yml` for self-hosting
|
|
161
|
+
- **Local** — starts the server immediately on localhost (dev/testing)
|
|
162
|
+
|
|
163
|
+
### Step 4: Custom Domain (optional)
|
|
164
|
+
Add a custom domain (e.g., `agents.acme.com`) with CNAME setup instructions.
|
|
165
|
+
|
|
166
|
+
---
|
|
167
|
+
|
|
168
|
+
## Database Support
|
|
169
|
+
|
|
170
|
+
Enterprise uses an abstract `DatabaseAdapter` interface. All 10 backends implement the same methods — you pick the one that fits your infrastructure.
|
|
171
|
+
|
|
172
|
+
| Database | Type | Connection | Best For |
|
|
173
|
+
|----------|------|------------|----------|
|
|
174
|
+
| **SQLite** | Embedded SQL | File path | Local dev, single-server, prototyping |
|
|
175
|
+
| **PostgreSQL** | Hosted SQL | Connection string | Production, most cloud providers |
|
|
176
|
+
| **MySQL** | Hosted SQL | Connection string | Existing MySQL infrastructure |
|
|
177
|
+
| **MongoDB** | NoSQL | Connection URI | Document-oriented workloads |
|
|
178
|
+
| **DynamoDB** | NoSQL | AWS credentials | AWS-native, serverless scale |
|
|
179
|
+
| **Turso / LibSQL** | Edge SQL | URL + token | Edge deployments, global distribution |
|
|
180
|
+
| **Supabase** | Managed Postgres | Connection string | Supabase ecosystem |
|
|
181
|
+
| **Neon** | Serverless Postgres | Connection string | Serverless, branching |
|
|
182
|
+
| **PlanetScale** | Managed MySQL | Connection string | PlanetScale ecosystem |
|
|
183
|
+
| **CockroachDB** | Distributed SQL | Connection string | Multi-region, high availability |
|
|
184
|
+
|
|
185
|
+
### Adapter Pattern
|
|
186
|
+
|
|
187
|
+
Every adapter extends `DatabaseAdapter` and implements:
|
|
188
|
+
|
|
189
|
+
```typescript
|
|
190
|
+
// Core operations
|
|
191
|
+
migrate(): Promise<void>
|
|
192
|
+
disconnect(): Promise<void>
|
|
193
|
+
getStats(): Promise<Stats>
|
|
194
|
+
|
|
195
|
+
// Users
|
|
196
|
+
createUser(input: UserInput): Promise<User>
|
|
197
|
+
getUserByEmail(email: string): Promise<User | null>
|
|
198
|
+
validatePassword(email: string, password: string): Promise<User | null>
|
|
199
|
+
|
|
200
|
+
// Agents
|
|
201
|
+
createAgent(input: AgentInput): Promise<Agent>
|
|
202
|
+
listAgents(filters?): Promise<Agent[]>
|
|
203
|
+
getAgent(id: string): Promise<Agent | null>
|
|
204
|
+
updateAgent(id: string, updates): Promise<Agent>
|
|
205
|
+
deleteAgent(id: string): Promise<void>
|
|
206
|
+
|
|
207
|
+
// API Keys
|
|
208
|
+
createApiKey(input: ApiKeyInput): Promise<ApiKey>
|
|
209
|
+
validateApiKey(key: string): Promise<ApiKey | null>
|
|
210
|
+
revokeApiKey(id: string): Promise<void>
|
|
211
|
+
|
|
212
|
+
// Audit Log
|
|
213
|
+
logEvent(event: AuditEvent): Promise<void>
|
|
214
|
+
getAuditLog(filters: AuditFilters): Promise<AuditEvent[]>
|
|
215
|
+
|
|
216
|
+
// Settings
|
|
217
|
+
getSettings(): Promise<CompanySettings>
|
|
218
|
+
updateSettings(updates): Promise<CompanySettings>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### MongoDB Notes
|
|
222
|
+
- Uses `_id` field directly (stores `randomUUID()` as `_id`)
|
|
223
|
+
- Indexes created on `email`, `apiKey`, `createdAt`
|
|
224
|
+
|
|
225
|
+
### DynamoDB Notes
|
|
226
|
+
- Single-table design with PK prefix pattern (`USER#`, `AGENT#`, `KEY#`, `AUDIT#`)
|
|
227
|
+
- GSI1 for secondary access patterns
|
|
228
|
+
- All entities in one table for cost efficiency
|
|
229
|
+
|
|
230
|
+
### Creating a Custom Adapter
|
|
231
|
+
|
|
232
|
+
```typescript
|
|
233
|
+
import { DatabaseAdapter } from '@agenticmail/enterprise';
|
|
234
|
+
|
|
235
|
+
class MyAdapter extends DatabaseAdapter {
|
|
236
|
+
async migrate() { /* create tables/collections */ }
|
|
237
|
+
async createUser(input) { /* ... */ }
|
|
238
|
+
// ... implement all abstract methods
|
|
239
|
+
}
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
---
|
|
243
|
+
|
|
244
|
+
## The Engine
|
|
245
|
+
|
|
246
|
+
The Engine is the brain of Enterprise — 11 subsystems that handle everything from "what can this agent do?" to "deploy it to production and watch it run."
|
|
247
|
+
|
|
248
|
+
### 1. Skills & Permissions
|
|
249
|
+
|
|
250
|
+
**38 built-in skills** organized into categories:
|
|
251
|
+
|
|
252
|
+
| Category | Skills |
|
|
253
|
+
|----------|--------|
|
|
254
|
+
| Communication | Email Management, SMS & Phone, Calendar, Messaging |
|
|
255
|
+
| Research | Web Search, Web Browsing, News Monitoring, Academic Research |
|
|
256
|
+
| Development | Code Execution, Git & GitHub, Database, API Integration |
|
|
257
|
+
| Content | Writing, Image Generation, Audio/TTS, Video Processing |
|
|
258
|
+
| Productivity | Task Management, Note Taking, File Management, Spreadsheets |
|
|
259
|
+
| System | System Administration, Docker, Network, Security |
|
|
260
|
+
| AI/ML | Model Inference, RAG/Knowledge Base, Agent Orchestration |
|
|
261
|
+
| Business | CRM, Analytics, Billing, HR |
|
|
262
|
+
| IoT/Smart Home | Home Automation, Camera/Surveillance, Media Playback |
|
|
263
|
+
| Custom | Custom Tools (user-defined) |
|
|
264
|
+
|
|
265
|
+
Each skill defines:
|
|
266
|
+
- **Tools** — which tool IDs are included (mapped to real OpenClaw + AgenticMail tool IDs)
|
|
267
|
+
- **Config fields** — what settings the skill needs (API keys, hostnames, etc.)
|
|
268
|
+
- **Risk level** — low, medium, high, critical
|
|
269
|
+
- **Side effects** — what the skill can affect (network, filesystem, email, etc.)
|
|
270
|
+
|
|
271
|
+
**5 preset permission profiles:**
|
|
272
|
+
|
|
273
|
+
| Profile | Description | Tools | Risk |
|
|
274
|
+
|---------|-------------|-------|------|
|
|
275
|
+
| Research Assistant | Web search, reading, note-taking | ~25 | Low |
|
|
276
|
+
| Customer Support | Email, messaging, CRM, KB search | ~35 | Medium |
|
|
277
|
+
| Developer | Code, Git, Docker, APIs, databases | ~45 | High |
|
|
278
|
+
| Full Access | Everything enabled | All | Critical |
|
|
279
|
+
| Sandbox | Minimal tools, no external access | ~10 | Low |
|
|
280
|
+
|
|
281
|
+
**How permissions work:**
|
|
282
|
+
|
|
283
|
+
```typescript
|
|
284
|
+
const engine = new PermissionEngine();
|
|
285
|
+
|
|
286
|
+
// Check if an agent can use a tool
|
|
287
|
+
const result = engine.checkPermission(agentProfile, 'agenticmail_send');
|
|
288
|
+
// → { allowed: true, reason: 'Granted by Email Management skill' }
|
|
289
|
+
|
|
290
|
+
// Or with approval required
|
|
291
|
+
const result2 = engine.checkPermission(agentProfile, 'exec');
|
|
292
|
+
// → { allowed: false, requiresApproval: true, reason: 'Code Execution requires admin approval' }
|
|
293
|
+
```
|
|
294
|
+
|
|
295
|
+
### 2. Agent Configuration
|
|
296
|
+
|
|
297
|
+
Generates all the files an agent needs to run:
|
|
298
|
+
|
|
299
|
+
- **SOUL.md** — personality, tone, boundaries
|
|
300
|
+
- **AGENTS.md** — workspace conventions
|
|
301
|
+
- **USER.md** — who the agent serves
|
|
302
|
+
- **TOOLS.md** — environment-specific tool notes
|
|
303
|
+
- **Gateway config** — OpenClaw `openclaw.json` with plugins, channels, tool policies
|
|
304
|
+
- **Deploy scripts** — Dockerfile, docker-compose, startup scripts
|
|
305
|
+
|
|
306
|
+
```typescript
|
|
307
|
+
const generator = new AgentConfigGenerator();
|
|
308
|
+
const config = generator.generate({
|
|
309
|
+
name: 'support-bot',
|
|
310
|
+
role: 'Customer Support Agent',
|
|
311
|
+
skills: ['email-management', 'crm', 'knowledge-base'],
|
|
312
|
+
channels: [{ type: 'email' }, { type: 'slack', webhook: '...' }],
|
|
313
|
+
deployment: { target: 'docker' },
|
|
314
|
+
});
|
|
315
|
+
// → { workspace: { 'SOUL.md': '...', ... }, gateway: { ... }, deploy: { ... } }
|
|
316
|
+
```
|
|
317
|
+
|
|
318
|
+
### 3. Deployment Engine
|
|
319
|
+
|
|
320
|
+
Provisions and manages agent infrastructure:
|
|
321
|
+
|
|
322
|
+
- **Docker** — Generates Dockerfile + compose, builds image, starts container
|
|
323
|
+
- **VPS** — SSH into a server, install dependencies, configure systemd service
|
|
324
|
+
- **Fly.io** — Creates Fly app, sets secrets, deploys
|
|
325
|
+
- **Railway** — Generates Railway config, links project
|
|
326
|
+
|
|
327
|
+
Each deployment goes through phases:
|
|
328
|
+
1. **Validate** — check config, verify credentials
|
|
329
|
+
2. **Provision** — create infrastructure resources
|
|
330
|
+
3. **Configure** — write config files, set environment variables
|
|
331
|
+
4. **Deploy** — push code/image, start the agent
|
|
332
|
+
5. **Verify** — health check, confirm agent is responding
|
|
333
|
+
|
|
334
|
+
```typescript
|
|
335
|
+
const deployer = new DeploymentEngine();
|
|
336
|
+
const result = await deployer.deploy({
|
|
337
|
+
agentId: 'agent-123',
|
|
338
|
+
target: 'docker',
|
|
339
|
+
config: { /* ... */ },
|
|
340
|
+
});
|
|
341
|
+
// → { status: 'deployed', url: 'http://...', phases: [...] }
|
|
342
|
+
```
|
|
343
|
+
|
|
344
|
+
### 4. Approval Workflows
|
|
345
|
+
|
|
346
|
+
Human-in-the-loop for sensitive operations:
|
|
347
|
+
|
|
348
|
+
- Define **policies** — which actions need approval and from whom
|
|
349
|
+
- Agents **request** approval when they hit a policy boundary
|
|
350
|
+
- Admins **approve or reject** from the dashboard or via API
|
|
351
|
+
- Supports **auto-approve** rules (e.g., "auto-approve emails to internal domains")
|
|
352
|
+
- **Escalation** — unreviewed requests escalate after a configurable timeout
|
|
353
|
+
|
|
354
|
+
```typescript
|
|
355
|
+
const approvals = new ApprovalEngine(db);
|
|
356
|
+
|
|
357
|
+
// Create a policy
|
|
358
|
+
await approvals.createPolicy({
|
|
359
|
+
action: 'send_external_email',
|
|
360
|
+
requiredRole: 'admin',
|
|
361
|
+
autoApproveRules: [{ condition: 'recipient_domain', value: 'acme.com' }],
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
// Agent requests approval
|
|
365
|
+
const request = await approvals.request({
|
|
366
|
+
agentId: 'agent-123',
|
|
367
|
+
action: 'send_external_email',
|
|
368
|
+
details: { to: 'client@external.com', subject: '...' },
|
|
369
|
+
});
|
|
370
|
+
// → { id: 'req-456', status: 'pending' }
|
|
371
|
+
|
|
372
|
+
// Admin approves
|
|
373
|
+
await approvals.decide(request.id, { approved: true, decidedBy: 'admin-1' });
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
### 5. Agent Lifecycle
|
|
377
|
+
|
|
378
|
+
State machine for agent lifecycle management:
|
|
379
|
+
|
|
380
|
+
```
|
|
381
|
+
created → provisioning → running → paused → running
|
|
382
|
+
→ stopped → archived
|
|
383
|
+
→ error → running (auto-recovery)
|
|
384
|
+
```
|
|
385
|
+
|
|
386
|
+
- **Health checks** — periodic pings, response time tracking, error rate monitoring
|
|
387
|
+
- **Auto-recovery** — configurable restart attempts on failure
|
|
388
|
+
- **Usage tracking** — token consumption, API calls, cost estimation
|
|
389
|
+
- **Events** — every state transition logged with timestamp and reason
|
|
390
|
+
|
|
391
|
+
```typescript
|
|
392
|
+
const lifecycle = new AgentLifecycleManager(db);
|
|
393
|
+
|
|
394
|
+
// Get agent status
|
|
395
|
+
const agent = await lifecycle.getAgent('agent-123');
|
|
396
|
+
// → { state: 'running', health: { status: 'healthy', lastCheck: '...', uptime: 86400 }, usage: { tokens: 1500000, cost: 12.50 } }
|
|
397
|
+
|
|
398
|
+
// Pause an agent
|
|
399
|
+
await lifecycle.transition('agent-123', 'pause', { reason: 'Maintenance window' });
|
|
400
|
+
|
|
401
|
+
// Resume
|
|
402
|
+
await lifecycle.transition('agent-123', 'resume');
|
|
403
|
+
```
|
|
404
|
+
|
|
405
|
+
### 6. Knowledge Base
|
|
406
|
+
|
|
407
|
+
Document ingestion and retrieval for agent knowledge:
|
|
408
|
+
|
|
409
|
+
- **Upload documents** — PDF, Markdown, plain text, HTML
|
|
410
|
+
- **Chunking** — automatic splitting into retrievable segments
|
|
411
|
+
- **Search** — semantic search across knowledge bases
|
|
412
|
+
- **Per-agent or shared** — knowledge bases can be private or shared across agents
|
|
413
|
+
|
|
414
|
+
```typescript
|
|
415
|
+
const kb = new KnowledgeBaseEngine(db);
|
|
416
|
+
|
|
417
|
+
// Create a knowledge base
|
|
418
|
+
const base = await kb.create({ name: 'Company Policies', agentIds: ['agent-1', 'agent-2'] });
|
|
419
|
+
|
|
420
|
+
// Add a document
|
|
421
|
+
await kb.addDocument(base.id, { title: 'PTO Policy', content: '...', format: 'markdown' });
|
|
422
|
+
|
|
423
|
+
// Search
|
|
424
|
+
const results = await kb.search(base.id, 'how many vacation days');
|
|
425
|
+
// → [{ chunk: '...', score: 0.92, document: 'PTO Policy' }]
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
### 7. Multi-Tenant Isolation
|
|
429
|
+
|
|
430
|
+
Organizations, plans, and resource limits:
|
|
431
|
+
|
|
432
|
+
**Plan Tiers:**
|
|
433
|
+
|
|
434
|
+
| Feature | Free | Team | Enterprise | Self-Hosted |
|
|
435
|
+
|---------|------|------|-----------|-------------|
|
|
436
|
+
| Agents | 3 | 25 | Unlimited | Unlimited |
|
|
437
|
+
| Users | 1 | 10 | Unlimited | Unlimited |
|
|
438
|
+
| Knowledge Bases | 1 | 10 | Unlimited | Unlimited |
|
|
439
|
+
| SSO | No | No | Yes | Yes |
|
|
440
|
+
| Audit Retention | 7 days | 90 days | Unlimited | Unlimited |
|
|
441
|
+
| Custom Domain | No | Yes | Yes | Yes |
|
|
442
|
+
| White-Label | No | No | Yes | Yes |
|
|
443
|
+
| Support | Community | Email | Priority | Self-serve |
|
|
444
|
+
|
|
445
|
+
```typescript
|
|
446
|
+
const tenants = new TenantManager(db);
|
|
447
|
+
|
|
448
|
+
// Create an organization
|
|
449
|
+
const org = await tenants.createOrg({ name: 'Acme Inc', plan: 'team', adminEmail: 'admin@acme.com' });
|
|
450
|
+
|
|
451
|
+
// Check limits
|
|
452
|
+
const canCreate = await tenants.checkLimit(org.id, 'agents');
|
|
453
|
+
// → { allowed: true, current: 5, limit: 25 }
|
|
454
|
+
|
|
455
|
+
// Get usage
|
|
456
|
+
const usage = await tenants.getUsage(org.id);
|
|
457
|
+
// → { agents: 5, users: 3, knowledgeBases: 2, storageBytes: 10485760 }
|
|
458
|
+
```
|
|
459
|
+
|
|
460
|
+
### 8. Activity Tracking
|
|
461
|
+
|
|
462
|
+
Real-time monitoring of everything agents do:
|
|
463
|
+
|
|
464
|
+
- **Tool calls** — which tools, when, duration, success/failure
|
|
465
|
+
- **Conversations** — message count, token usage, cost
|
|
466
|
+
- **Timeline** — chronological view of all agent activity
|
|
467
|
+
- **Aggregations** — daily/weekly/monthly summaries
|
|
468
|
+
|
|
469
|
+
```typescript
|
|
470
|
+
const activity = new ActivityTracker(db);
|
|
471
|
+
|
|
472
|
+
// Record a tool call
|
|
473
|
+
await activity.recordToolCall({
|
|
474
|
+
agentId: 'agent-123',
|
|
475
|
+
tool: 'agenticmail_send',
|
|
476
|
+
duration: 450,
|
|
477
|
+
success: true,
|
|
478
|
+
metadata: { to: 'user@example.com' },
|
|
479
|
+
});
|
|
480
|
+
|
|
481
|
+
// Get agent timeline
|
|
482
|
+
const timeline = await activity.getTimeline('agent-123', { limit: 50 });
|
|
483
|
+
// → [{ type: 'tool_call', tool: '...', timestamp: '...', ... }, ...]
|
|
484
|
+
|
|
485
|
+
// Get stats
|
|
486
|
+
const stats = await activity.getStats('agent-123', { period: 'day' });
|
|
487
|
+
// → { toolCalls: 142, conversations: 8, tokensUsed: 450000, estimatedCost: 3.75 }
|
|
488
|
+
```
|
|
489
|
+
|
|
490
|
+
### 9. Tool Catalog
|
|
491
|
+
|
|
492
|
+
Maps real OpenClaw and AgenticMail tool IDs to skills:
|
|
493
|
+
|
|
494
|
+
- **167 total tools** cataloged (63 OpenClaw core + 62 AgenticMail MCP + 42 shell commands)
|
|
495
|
+
- Each tool mapped to one or more skills
|
|
496
|
+
- Used by the Permission Engine to resolve skill → tool access
|
|
497
|
+
|
|
498
|
+
```typescript
|
|
499
|
+
import { ALL_TOOLS, getToolsBySkill, generateOpenClawToolPolicy } from '@agenticmail/enterprise';
|
|
500
|
+
|
|
501
|
+
// Get all tools for a skill
|
|
502
|
+
const emailTools = getToolsBySkill('email-management');
|
|
503
|
+
// → ['agenticmail_send', 'agenticmail_inbox', 'agenticmail_reply', ...]
|
|
504
|
+
|
|
505
|
+
// Generate OpenClaw tool policy
|
|
506
|
+
const policy = generateOpenClawToolPolicy(['email-management', 'web-search']);
|
|
507
|
+
// → { allow: ['agenticmail_send', ...], deny: [...] }
|
|
508
|
+
```
|
|
509
|
+
|
|
510
|
+
### 10. OpenClaw Hook
|
|
511
|
+
|
|
512
|
+
Middleware that integrates with OpenClaw's plugin system:
|
|
513
|
+
|
|
514
|
+
- **Permission enforcement** — checks every tool call against the agent's permission profile
|
|
515
|
+
- **Activity logging** — records tool calls to the activity tracker
|
|
516
|
+
- **Approval gating** — blocks tool calls that require approval
|
|
517
|
+
- **Permission caching** — avoids repeated DB lookups on high-frequency calls
|
|
518
|
+
|
|
519
|
+
```typescript
|
|
520
|
+
import { createEnterpriseHook } from '@agenticmail/enterprise';
|
|
521
|
+
|
|
522
|
+
const hook = createEnterpriseHook({
|
|
523
|
+
apiUrl: 'http://localhost:3000',
|
|
524
|
+
apiKey: 'ek_...',
|
|
525
|
+
agentId: 'agent-123',
|
|
526
|
+
});
|
|
527
|
+
|
|
528
|
+
// In OpenClaw plugin:
|
|
529
|
+
// hook.beforeToolCall(toolName, args) → { allowed, requiresApproval, reason }
|
|
530
|
+
// hook.afterToolCall(toolName, result, duration) → void (logs activity)
|
|
531
|
+
```
|
|
532
|
+
|
|
533
|
+
### 11. AgenticMail Bridge
|
|
534
|
+
|
|
535
|
+
Connects the Engine to an existing AgenticMail instance:
|
|
536
|
+
|
|
537
|
+
- **Account sync** — creates/manages agent email accounts
|
|
538
|
+
- **Tool interception** — wraps AgenticMail tool calls with permission checks
|
|
539
|
+
- **Event forwarding** — pipes AgenticMail events (new email, task completion) to the activity tracker
|
|
540
|
+
|
|
541
|
+
```typescript
|
|
542
|
+
import { createAgenticMailBridge } from '@agenticmail/enterprise';
|
|
543
|
+
|
|
544
|
+
const bridge = createAgenticMailBridge({
|
|
545
|
+
agenticmailUrl: 'http://localhost:3100',
|
|
546
|
+
masterKey: 'mk_...',
|
|
547
|
+
});
|
|
548
|
+
|
|
549
|
+
// Sync an agent's email account
|
|
550
|
+
await bridge.ensureAgent({ name: 'support-bot', role: 'customer-support' });
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
---
|
|
554
|
+
|
|
555
|
+
## REST API
|
|
556
|
+
|
|
557
|
+
### Authentication
|
|
558
|
+
|
|
559
|
+
Two methods:
|
|
560
|
+
|
|
561
|
+
**JWT Token** (for dashboard users):
|
|
562
|
+
```
|
|
563
|
+
POST /auth/login
|
|
564
|
+
{ "email": "admin@acme.com", "password": "..." }
|
|
565
|
+
→ { "token": "eyJ...", "user": { ... } }
|
|
566
|
+
|
|
567
|
+
# Then:
|
|
568
|
+
Authorization: Bearer eyJ...
|
|
569
|
+
```
|
|
570
|
+
|
|
571
|
+
**API Key** (for programmatic access):
|
|
572
|
+
```
|
|
573
|
+
X-API-Key: ek_abc123...
|
|
574
|
+
```
|
|
575
|
+
|
|
576
|
+
API keys have scoped permissions and are created through the admin API.
|
|
577
|
+
|
|
578
|
+
### Admin Endpoints
|
|
579
|
+
|
|
580
|
+
| Method | Path | Description |
|
|
581
|
+
|--------|------|-------------|
|
|
582
|
+
| GET | `/api/stats` | Dashboard statistics |
|
|
583
|
+
| GET | `/api/agents` | List agents |
|
|
584
|
+
| POST | `/api/agents` | Create agent |
|
|
585
|
+
| GET | `/api/agents/:id` | Get agent details |
|
|
586
|
+
| PUT | `/api/agents/:id` | Update agent |
|
|
587
|
+
| DELETE | `/api/agents/:id` | Delete agent |
|
|
588
|
+
| GET | `/api/users` | List users |
|
|
589
|
+
| POST | `/api/users` | Create user |
|
|
590
|
+
| GET | `/api/audit` | Query audit log |
|
|
591
|
+
| POST | `/api/keys` | Create API key |
|
|
592
|
+
| DELETE | `/api/keys/:id` | Revoke API key |
|
|
593
|
+
| GET | `/api/settings` | Get company settings |
|
|
594
|
+
| PUT | `/api/settings` | Update settings |
|
|
595
|
+
|
|
596
|
+
### Engine Endpoints
|
|
597
|
+
|
|
598
|
+
| Method | Path | Description |
|
|
599
|
+
|--------|------|-------------|
|
|
600
|
+
| GET | `/api/engine/skills` | List all 38 skills |
|
|
601
|
+
| GET | `/api/engine/skills/:id` | Get skill details + tools |
|
|
602
|
+
| GET | `/api/engine/profiles/presets` | List 5 permission presets |
|
|
603
|
+
| GET | `/api/engine/profiles/:agentId` | Get agent's permission profile |
|
|
604
|
+
| PUT | `/api/engine/profiles/:agentId` | Update agent's permission profile |
|
|
605
|
+
| POST | `/api/engine/profiles/:agentId/apply-preset` | Apply a preset to agent |
|
|
606
|
+
| POST | `/api/engine/permissions/check` | Check tool permission |
|
|
607
|
+
| GET | `/api/engine/permissions/:agentId/tools` | List tools available to agent |
|
|
608
|
+
| GET | `/api/engine/permissions/:agentId/policy` | Generate OpenClaw tool policy |
|
|
609
|
+
| GET | `/api/engine/stats` | Engine statistics |
|
|
610
|
+
| POST | `/api/engine/generate-config` | Generate agent config files |
|
|
611
|
+
| POST | `/api/engine/deploy` | Deploy an agent |
|
|
612
|
+
| GET | `/api/engine/deployments` | List deployments |
|
|
613
|
+
| GET | `/api/engine/deployments/:id` | Deployment status |
|
|
614
|
+
| POST | `/api/engine/approvals` | Create approval request |
|
|
615
|
+
| GET | `/api/engine/approvals` | List pending approvals |
|
|
616
|
+
| PUT | `/api/engine/approvals/:id` | Approve/reject |
|
|
617
|
+
| GET | `/api/engine/agents/:id/lifecycle` | Agent lifecycle state |
|
|
618
|
+
| POST | `/api/engine/agents/:id/transition` | Trigger state transition |
|
|
619
|
+
| GET | `/api/engine/agents/:id/timeline` | Agent activity timeline |
|
|
620
|
+
| POST | `/api/engine/knowledge-bases` | Create knowledge base |
|
|
621
|
+
| POST | `/api/engine/knowledge-bases/:id/documents` | Add document |
|
|
622
|
+
| GET | `/api/engine/knowledge-bases/:id/search` | Search KB |
|
|
623
|
+
| GET | `/api/engine/tools` | Full tool catalog |
|
|
624
|
+
| POST | `/api/engine/tool-policy` | Generate tool policy for skills |
|
|
625
|
+
|
|
626
|
+
---
|
|
627
|
+
|
|
628
|
+
## Dashboard
|
|
629
|
+
|
|
630
|
+
The admin dashboard is a single HTML file using React 18 from CDN — no build step required. It includes:
|
|
631
|
+
|
|
632
|
+
- **Login page** with JWT authentication
|
|
633
|
+
- **Overview** with agent counts, activity stats, system health
|
|
634
|
+
- **Agent management** — create, configure, deploy, monitor
|
|
635
|
+
- **Audit log** — searchable, filterable event history
|
|
636
|
+
- **API key management** — create scoped keys, revoke
|
|
637
|
+
- **Settings** — company info, custom domain, plan management
|
|
638
|
+
- **Dark and light mode** themes
|
|
639
|
+
|
|
640
|
+
The dashboard is served automatically at `/dashboard` when the server starts. It communicates with the API using the same JWT/API key auth as any other client.
|
|
641
|
+
|
|
642
|
+
### Building Your Own Frontend
|
|
643
|
+
|
|
644
|
+
The dashboard is a reference implementation. You can build your own UI by hitting the REST API directly. Every API response follows a consistent format:
|
|
645
|
+
|
|
646
|
+
```json
|
|
647
|
+
{
|
|
648
|
+
"data": { ... },
|
|
649
|
+
"meta": { "total": 42, "page": 1, "limit": 20 }
|
|
650
|
+
}
|
|
651
|
+
```
|
|
652
|
+
|
|
653
|
+
Errors:
|
|
654
|
+
```json
|
|
655
|
+
{
|
|
656
|
+
"error": "Description of what went wrong",
|
|
657
|
+
"code": "VALIDATION_ERROR",
|
|
658
|
+
"details": { ... }
|
|
659
|
+
}
|
|
660
|
+
```
|
|
661
|
+
|
|
662
|
+
---
|
|
663
|
+
|
|
664
|
+
## Deployment
|
|
665
|
+
|
|
666
|
+
### AgenticMail Cloud
|
|
667
|
+
|
|
668
|
+
Managed hosting on Fly.io infrastructure. Instant URL at `company.agenticmail.cloud`.
|
|
669
|
+
|
|
670
|
+
```bash
|
|
671
|
+
npx @agenticmail/enterprise
|
|
672
|
+
# → Select "AgenticMail Cloud"
|
|
673
|
+
# → Dashboard live at https://acme.agenticmail.cloud
|
|
674
|
+
```
|
|
675
|
+
|
|
676
|
+
Optional custom domain via CNAME:
|
|
677
|
+
```
|
|
678
|
+
agents.acme.com → acme.agenticmail.cloud
|
|
679
|
+
```
|
|
680
|
+
|
|
681
|
+
### Fly.io
|
|
682
|
+
|
|
683
|
+
Deploy to your own Fly.io account:
|
|
684
|
+
|
|
685
|
+
```bash
|
|
686
|
+
npx @agenticmail/enterprise
|
|
687
|
+
# → Select "Fly.io"
|
|
688
|
+
# → Generates fly.toml
|
|
689
|
+
|
|
690
|
+
fly launch --copy-config
|
|
691
|
+
fly secrets set DATABASE_URL="..." JWT_SECRET="..."
|
|
692
|
+
fly deploy
|
|
693
|
+
```
|
|
694
|
+
|
|
695
|
+
### Docker
|
|
696
|
+
|
|
697
|
+
Self-hosted with Docker Compose:
|
|
698
|
+
|
|
699
|
+
```bash
|
|
700
|
+
npx @agenticmail/enterprise
|
|
701
|
+
# → Select "Docker"
|
|
702
|
+
# → Generates docker-compose.yml
|
|
703
|
+
|
|
704
|
+
docker compose up -d
|
|
705
|
+
# → Dashboard at http://localhost:3000
|
|
706
|
+
```
|
|
707
|
+
|
|
708
|
+
### Local Development
|
|
709
|
+
|
|
710
|
+
Start immediately for testing:
|
|
711
|
+
|
|
712
|
+
```bash
|
|
713
|
+
npx @agenticmail/enterprise
|
|
714
|
+
# → Select "Local"
|
|
715
|
+
# → Server runs on http://localhost:3000
|
|
716
|
+
```
|
|
717
|
+
|
|
718
|
+
---
|
|
719
|
+
|
|
720
|
+
## Server Configuration
|
|
721
|
+
|
|
722
|
+
```typescript
|
|
723
|
+
import { createAdapter, createServer } from '@agenticmail/enterprise';
|
|
724
|
+
|
|
725
|
+
const db = await createAdapter({
|
|
726
|
+
type: 'postgres',
|
|
727
|
+
connectionString: 'postgresql://user:pass@host:5432/db',
|
|
728
|
+
});
|
|
729
|
+
await db.migrate();
|
|
730
|
+
|
|
731
|
+
const server = createServer({
|
|
732
|
+
port: 3000,
|
|
733
|
+
db,
|
|
734
|
+
jwtSecret: 'your-secret-here',
|
|
735
|
+
|
|
736
|
+
// Optional
|
|
737
|
+
corsOrigins: ['https://app.acme.com'],
|
|
738
|
+
rateLimit: 120, // requests per minute per IP
|
|
739
|
+
trustedProxies: ['10.0.0.0/8'],
|
|
740
|
+
logging: true,
|
|
741
|
+
});
|
|
742
|
+
|
|
743
|
+
await server.start();
|
|
744
|
+
```
|
|
745
|
+
|
|
746
|
+
---
|
|
747
|
+
|
|
748
|
+
## Middleware
|
|
749
|
+
|
|
750
|
+
All middleware is exported for use in custom server setups:
|
|
751
|
+
|
|
752
|
+
| Middleware | Description |
|
|
753
|
+
|-----------|-------------|
|
|
754
|
+
| `requestIdMiddleware()` | Adds `X-Request-Id` header to every request |
|
|
755
|
+
| `requestLogger()` | Logs method, path, status, duration |
|
|
756
|
+
| `rateLimiter(opts)` | Per-IP rate limiting with configurable window |
|
|
757
|
+
| `securityHeaders()` | Sets security headers (CSP, HSTS, X-Frame-Options, etc.) |
|
|
758
|
+
| `errorHandler()` | Catches unhandled errors, returns JSON |
|
|
759
|
+
| `auditLogger(db)` | Logs all mutations to the audit trail |
|
|
760
|
+
| `requireRole(role)` | RBAC middleware — requires specific user role |
|
|
761
|
+
| `validate(schema)` | Request body validation |
|
|
762
|
+
|
|
763
|
+
---
|
|
764
|
+
|
|
765
|
+
## Resilience
|
|
766
|
+
|
|
767
|
+
Built-in resilience primitives:
|
|
768
|
+
|
|
769
|
+
| Component | Description |
|
|
770
|
+
|-----------|-------------|
|
|
771
|
+
| `CircuitBreaker` | Fails fast after N consecutive errors, auto-recovers after cooldown |
|
|
772
|
+
| `HealthMonitor` | Periodic health checks with configurable thresholds |
|
|
773
|
+
| `withRetry(fn, opts)` | Retry with exponential backoff |
|
|
774
|
+
| `RateLimiter` | Token bucket rate limiter |
|
|
775
|
+
| `KeyedRateLimiter` | Per-key rate limiting (e.g., per-user, per-IP) |
|
|
776
|
+
|
|
777
|
+
```typescript
|
|
778
|
+
import { CircuitBreaker, withRetry, HealthMonitor } from '@agenticmail/enterprise';
|
|
779
|
+
|
|
780
|
+
// Circuit breaker wrapping a database call
|
|
781
|
+
const breaker = new CircuitBreaker({ failureThreshold: 5, recoveryTimeMs: 30000 });
|
|
782
|
+
const result = await breaker.execute(() => db.query('SELECT ...'));
|
|
783
|
+
|
|
784
|
+
// Retry with backoff
|
|
785
|
+
const data = await withRetry(() => fetch('https://api.example.com'), {
|
|
786
|
+
maxRetries: 3,
|
|
787
|
+
baseDelayMs: 1000,
|
|
788
|
+
backoffMultiplier: 2,
|
|
789
|
+
});
|
|
790
|
+
```
|
|
791
|
+
|
|
792
|
+
---
|
|
793
|
+
|
|
794
|
+
## Programmatic Usage
|
|
795
|
+
|
|
796
|
+
Use Enterprise as a library in your own application:
|
|
797
|
+
|
|
798
|
+
```typescript
|
|
799
|
+
import {
|
|
800
|
+
// Database
|
|
801
|
+
createAdapter,
|
|
802
|
+
|
|
803
|
+
// Server
|
|
804
|
+
createServer,
|
|
805
|
+
|
|
806
|
+
// Engine
|
|
807
|
+
PermissionEngine,
|
|
808
|
+
BUILTIN_SKILLS,
|
|
809
|
+
PRESET_PROFILES,
|
|
810
|
+
AgentConfigGenerator,
|
|
811
|
+
DeploymentEngine,
|
|
812
|
+
ApprovalEngine,
|
|
813
|
+
AgentLifecycleManager,
|
|
814
|
+
KnowledgeBaseEngine,
|
|
815
|
+
TenantManager,
|
|
816
|
+
ActivityTracker,
|
|
817
|
+
|
|
818
|
+
// Tool catalog
|
|
819
|
+
ALL_TOOLS,
|
|
820
|
+
getToolsBySkill,
|
|
821
|
+
generateOpenClawToolPolicy,
|
|
822
|
+
|
|
823
|
+
// Engine persistence
|
|
824
|
+
EngineDatabase,
|
|
825
|
+
|
|
826
|
+
// OpenClaw integration
|
|
827
|
+
createEnterpriseHook,
|
|
828
|
+
createAgenticMailBridge,
|
|
829
|
+
|
|
830
|
+
// Resilience
|
|
831
|
+
CircuitBreaker,
|
|
832
|
+
withRetry,
|
|
833
|
+
HealthMonitor,
|
|
834
|
+
|
|
835
|
+
// Middleware (for custom servers)
|
|
836
|
+
rateLimiter,
|
|
837
|
+
auditLogger,
|
|
838
|
+
requireRole,
|
|
839
|
+
} from '@agenticmail/enterprise';
|
|
840
|
+
```
|
|
841
|
+
|
|
842
|
+
---
|
|
843
|
+
|
|
844
|
+
## Security
|
|
845
|
+
|
|
846
|
+
- **JWT authentication** with configurable secret and expiry
|
|
847
|
+
- **API key authentication** with scoped permissions
|
|
848
|
+
- **RBAC** — owner, admin, member, viewer roles
|
|
849
|
+
- **Rate limiting** — per-IP, configurable limits
|
|
850
|
+
- **Audit logging** — every mutation logged with actor, action, resource, timestamp
|
|
851
|
+
- **Outbound email scanning** — inherited from AgenticMail core (blocks PII, credentials, secrets)
|
|
852
|
+
- **Security headers** — CSP, HSTS, X-Frame-Options, X-Content-Type-Options
|
|
853
|
+
- **Input validation** — all API inputs validated before processing
|
|
854
|
+
- **Circuit breaker** — protects against cascading failures
|
|
855
|
+
- **Graceful shutdown** — clean connection teardown on SIGINT/SIGTERM
|
|
856
|
+
|
|
857
|
+
---
|
|
858
|
+
|
|
859
|
+
## Project Structure
|
|
860
|
+
|
|
861
|
+
```
|
|
862
|
+
packages/enterprise/src/
|
|
863
|
+
├── cli.ts # Setup wizard (npx entry point)
|
|
864
|
+
├── server.ts # Hono API server
|
|
865
|
+
├── index.ts # Public exports
|
|
866
|
+
│
|
|
867
|
+
├── setup/ # Setup wizard modules
|
|
868
|
+
│ ├── index.ts # Wizard orchestrator
|
|
869
|
+
│ ├── company.ts # Step 1: Company info prompts
|
|
870
|
+
│ ├── database.ts # Step 2: Database selection + config
|
|
871
|
+
│ ├── deployment.ts # Step 3: Deployment target
|
|
872
|
+
│ ├── domain.ts # Step 4: Custom domain
|
|
873
|
+
│ └── provision.ts # Provisioning logic (DB, admin, deploy)
|
|
874
|
+
│
|
|
875
|
+
├── auth/
|
|
876
|
+
│ └── routes.ts # Login, token refresh, password reset
|
|
877
|
+
│
|
|
878
|
+
├── admin/
|
|
879
|
+
│ └── routes.ts # User/agent/key/audit CRUD
|
|
880
|
+
│
|
|
881
|
+
├── middleware/
|
|
882
|
+
│ └── index.ts # All middleware exports
|
|
883
|
+
│
|
|
884
|
+
├── db/ # Database adapters
|
|
885
|
+
│ ├── adapter.ts # Abstract DatabaseAdapter
|
|
886
|
+
│ ├── factory.ts # createAdapter() + getSupportedDatabases()
|
|
887
|
+
│ ├── sql-schema.ts # Shared SQL DDL
|
|
888
|
+
│ ├── sqlite.ts
|
|
889
|
+
│ ├── postgres.ts
|
|
890
|
+
│ ├── mysql.ts
|
|
891
|
+
│ ├── mongodb.ts
|
|
892
|
+
│ ├── dynamodb.ts
|
|
893
|
+
│ └── turso.ts
|
|
894
|
+
│
|
|
895
|
+
├── engine/ # Agent deployment platform
|
|
896
|
+
│ ├── index.ts # Public API (re-exports)
|
|
897
|
+
│ ├── skills.ts # 38 skills, 5 presets
|
|
898
|
+
│ ├── agent-config.ts # Config generator
|
|
899
|
+
│ ├── deployer.ts # Deployment engine
|
|
900
|
+
│ ├── approvals.ts # Approval workflows
|
|
901
|
+
│ ├── lifecycle.ts # Agent state machine
|
|
902
|
+
│ ├── knowledge.ts # Knowledge base
|
|
903
|
+
│ ├── tenant.ts # Multi-tenant manager
|
|
904
|
+
│ ├── activity.ts # Activity tracker
|
|
905
|
+
│ ├── tool-catalog.ts # Tool ID catalog
|
|
906
|
+
│ ├── openclaw-hook.ts # OpenClaw integration
|
|
907
|
+
│ ├── agenticmail-bridge.ts # AgenticMail integration
|
|
908
|
+
│ ├── db-adapter.ts # Engine DB persistence
|
|
909
|
+
│ ├── db-schema.ts # Engine DDL + migrations
|
|
910
|
+
│ └── routes.ts # Engine REST API
|
|
911
|
+
│
|
|
912
|
+
├── deploy/ # Deployment configs
|
|
913
|
+
│ ├── managed.ts # Cloud deploy + Docker/Fly/Railway generators
|
|
914
|
+
│ └── fly.ts # Fly.io API client
|
|
915
|
+
│
|
|
916
|
+
├── dashboard/
|
|
917
|
+
│ └── index.html # Admin UI (single HTML, React 18)
|
|
918
|
+
│
|
|
919
|
+
├── lib/
|
|
920
|
+
│ └── resilience.ts # CircuitBreaker, HealthMonitor, Retry, RateLimiter
|
|
921
|
+
│
|
|
922
|
+
└── ui/ # (future) Component library
|
|
923
|
+
```
|
|
924
|
+
|
|
925
|
+
---
|
|
926
|
+
|
|
927
|
+
## Author
|
|
928
|
+
|
|
929
|
+
Created by **[Ope Olatunji](https://github.com/ope-olatunji)**.
|
|
930
|
+
|
|
931
|
+
Part of the [AgenticMail](https://github.com/agenticmail/agenticmail) project — the first platform to give AI agents real email addresses and phone numbers.
|
|
932
|
+
|
|
933
|
+
- GitHub: [@ope-olatunji](https://github.com/ope-olatunji)
|
|
934
|
+
- Website: [agenticmail.io](https://agenticmail.io)
|
|
935
|
+
- Twitter: [@agenticmail](https://x.com/agenticmail)
|
|
936
|
+
|
|
937
|
+
## License
|
|
938
|
+
|
|
939
|
+
MIT — see [LICENSE](./LICENSE)
|