--- install scripts ---
### postinstall
node scripts/ensure-pm2-startup.cjs --quiet || true
--- package/package.json (excerpt) ---
{
"name": "@agenticmail/enterprise",
"version": "0.5.615",
"description": "AgenticMail Enterprise — cloud-hosted AI agent identity, email, auth & compliance for organizations",
"type": "module",
"bin": {
"agenticmail-enterprise": "bin/agenticmail-enterprise.cjs",
"enterprise": "bin/agenticmail-enterprise.cjs",
"agenticmail-registry": "dist/registry/cli.js",
"agenticmail-watchdog": "dist/watchdog.js"
},
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
}
},
"scripts": {
"build": "tsup src/index.ts src/cli.ts src/registry/cli.ts src/watchdog.ts --format esm --external better-sqlite3 --external mongodb --external mysql2 --external @libsql/client --external @aws-sdk/client-dynamodb --external @aws-sdk/lib-dynamodb --external @aws-sdk/client-s3 --external @aws-sdk/s3-request-presigner --external @google-cloud/storage --external @azure/storage-blob --external @mozilla/readability --external imapflow --external nodemailer --external linkedom --external postgres --external playwright-core --external ws --external express && mkdir -p dist/dashboard/components dist/dashboard/pages dist/dashboard/vendor dist/dashboard/assets dist/registry && cp src/dashboard/index.html dist/dashboard/ && cp src/dashboard/app.js dist/dashboard/ && cp src/dashboard/components/*.js dist/dashboard/components/ && cp src/dashboard/pages/*.js dist/dashboard/pages/ && rm -rf dist/dashboard/
--- package/scripts/preuninstall.js (excerpt) ---
#!/usr/bin/env node
/**
* Pre-uninstall cleanup for @agenticmail/enterprise
* Stops PM2 processes and removes LaunchAgent if present.
* Does NOT delete user data (database, config files) — that's the user's responsibility.
*/
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const os = require('os');
function run(cmd, opts = {}) {
try {
return execSync(cmd, { stdio: 'pipe', timeout: 10000, ...opts }).toString().trim();
} catch { return ''; }
}
function log(msg) { console.log(`[agenticmail-uninstall] ${msg}`); }
try {
// 1. Stop PM2 processes
const pm2List = run('pm2 jlist');
if (pm2List) {
try {
const procs = JSON.parse(pm2List);
const ours = procs.filter(p =>
p.name === 'enterprise' ||
(p.pm2_env && p.pm2_env.pm_exec_path && p.pm2_env.pm_exec_path.includes('agenticmail'))
);
for (const proc of ours) {
log(`Stopping PM2 process: ${proc.name} (pid ${proc.pid})`);
run(`pm2 delete ${proc.pm_id}`);
}
if (ours.length > 0) {
run('pm2 save');
log(`Stopped and removed ${ours.length} PM2 process(es)`);
}
} catch { /* pm2 not available or parse error */ }
}
// 2. Remove LaunchAgent (macOS auto-start)
if (process.platform === 'darwin') {
const plistDir = path.join(os.homedir(), 'Library', 'LaunchAgents');
const plistFiles = ['com.PM2.plist', 'com.agenticmail.plist', 'pm2.' + os.userInfo().username + '.
--- package/scripts/vm-setup.sh (excerpt) ---
#!/bin/bash
# ─────────────────────────────────────────────────────────────
# AgenticMail Enterprise — VM Setup Script
#
# Sets up a Linux VM (Ubuntu 22.04/24.04) with everything needed
# for full enterprise agent capabilities including:
# - Node.js 22
# - Chromium (headed via Xvfb virtual display)
# - PulseAudio (virtual audio for meetings)
# - v4l2loopback (virtual camera)
# - FFmpeg (recording/transcoding)
# - PostgreSQL client
# - Systemd service for auto-start
#
# Usage:
# curl -fsSL https://raw.githubusercontent.com/agenticmail/enterprise/main/scripts/vm-setup.sh | bash
# # or
# bash vm-setup.sh
#
# Tested on: Ubuntu 22.04 LTS, Ubuntu 24.04 LTS, Debian 12
# Recommended: Hetzner CPX31 (4 vCPU, 8GB RAM) — $15/mo
# ─────────────────────────────────────────────────────────────
set -euo pipefail
# Colors
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
BLUE='\033[0;34m'
NC='\033[0m'
log() { echo -e "${GREEN}[✓]${NC} $*"; }
warn() { echo -e "${YELLOW}[!]${NC} $*"; }
err() { echo -e "${RED}[✗]${NC} $*"; exit 1; }
step() { echo -e "\n${BLUE}━━━ $* ━━━${NC}"; }
# Must be root or sudo
if [ "$(id -u)" -ne 0 ]; then
err "Run as root: sudo bash vm-setup.sh"
fi
AGENT_USER="${AGENT_USER:-agenticmail}"
AGENT_HOME="/home/${AGENT_USER}"
AGENT_PORT="${AGENT_PORT:-8080}"
NODE_VERSION="22"
step "1/8 — System Update"
export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get upgrade -y -qq
log "System updated"
step "2/8 — Install Core Dependencies"
apt-get insta{
"name": "@agenticmail/enterprise",
"version": "0.5.615",
"description": "AgenticMail Enterprise — cloud-hosted AI agent identity, email, auth & compliance for organizations",
"type": "module",
"bin": {
"agenticmail-enterprise": "bin/agenticmail-enterprise.cjs",
"enterprise": "bin/agenticmail-enterprise.cjs",
"agenticmail-registry": "dist/registry/cli.js",
"agenticmail-watchdog": "dist/watchdog.js"
},
"exports": {
".": {
"import": "./dist/index.js",
"require": "./dist/index.cjs",
"types": "./dist/index.d.ts"
}
},
"scripts": {
"build": "tsup src/index.ts src/cli.ts src/registry/cli.ts src/watchdog.ts --format esm --external better-sqlite3 --external mongodb --external mysql2 --external @libsql/client --external @aws-sdk/client-dynamodb --external @aws-sdk/lib-dynamodb --external @aws-sdk/client-s3 --external @aws-sdk/s3-request-presigner --external @google-cloud/storage --external @azure/storage-blob --external @mozilla/readability --external imapflow --external nodemailer --external linkedom --external postgres --external playwright-core --external ws --external express && mkdir -p dist/dashboard/components dist/dashboard/pages dist/dashboard/vendor dist/dashboard/assets dist/registry && cp src/dashboard/index.html dist/dashboard/ && cp src/dashboard/app.js dist/dashboard/ && cp src/dashboard/components/*.js dist/dashboard/components/ && cp src/dashboard/pages/*.js dist/dashboard/pages/ && rm -rf dist/dashboard/
#!/usr/bin/env node
/**
* Pre-uninstall cleanup for @agenticmail/enterprise
* Stops PM2 processes and removes LaunchAgent if present.
* Does NOT delete user data (database, config files) — that's the user's responsibility.
*/
const { execSync } = require('child_process');
const fs = require('fs');
const path = require('path');
const os = require('os');
function run(cmd, opts = {}) {
try {
return execSync(cmd, { stdio: 'pipe', timeout: 10000, ...opts }).toString().trim();
} catch { return ''; }
}
function log(msg) { console.log(`[agenticmail-uninstall] ${msg}`); }
try {
// 1. Stop PM2 processes
const pm2List = run('pm2 jlist');
if (pm2List) {
try {
const procs = JSON.parse(pm2List);
const ours = procs.filter(p =>
p.name === 'enterprise' ||
(p.pm2_env && p.pm2_env.pm_exec_path && p.pm2_env.pm_exec_path.includes('agenticmail'))
);
for (const proc of ours) {
log(`Stopping PM2 process: ${proc.name} (pid ${proc.pid})`);
run(`pm2 delete ${proc.pm_id}`);
}
if (ours.length > 0) {
run('pm2 save');
log(`Stopped and removed ${ours.length} PM2 process(es)`);
}
} catch { /* pm2 not available or parse error */ }
}
// 2. Remove LaunchAgent (macOS auto-start)
if (process.platform === 'darwin') {
const plistDir = path.join(os.homedir(), 'Library', 'LaunchAgents');
const plistFiles = ['com.PM2.plist', 'com.agenticmail.plist', 'pm2.' + os.userInfo().username + '.