@agenticmail/enterprise 0.5.310 → 0.5.312
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/dist/agent-heartbeat-5Y7JCWDU.js +510 -0
- package/dist/agent-heartbeat-RLRA5KVZ.js +510 -0
- package/dist/chunk-EKMS2KSE.js +25098 -0
- package/dist/chunk-FNUFLQJ3.js +4909 -0
- package/dist/chunk-HP42WFMQ.js +4909 -0
- package/dist/chunk-HZZPIICV.js +25098 -0
- package/dist/chunk-MBT5ND3D.js +1519 -0
- package/dist/chunk-NM4KTDG2.js +4932 -0
- package/dist/chunk-OPOBUYJT.js +1519 -0
- package/dist/chunk-PFMIOSR5.js +1519 -0
- package/dist/chunk-VKSOKBVG.js +4932 -0
- package/dist/chunk-Y2KIY4BA.js +4969 -0
- package/dist/cli-agent-EV7RDHZ4.js +2169 -0
- package/dist/cli-agent-KWSWAFQU.js +2169 -0
- package/dist/cli-serve-COFEVLTD.js +143 -0
- package/dist/cli-serve-FE4CMMSN.js +143 -0
- package/dist/cli-serve-PSM73OAW.js +143 -0
- package/dist/cli.js +3 -3
- package/dist/dashboard/app.js +8 -1
- package/dist/index.js +4 -4
- package/dist/routes-A2PWCOQV.js +90 -0
- package/dist/routes-SL5Y25K3.js +90 -0
- package/dist/runtime-KFD322X5.js +45 -0
- package/dist/runtime-UCP46CVY.js +45 -0
- package/dist/server-6JMYVJVM.js +28 -0
- package/dist/server-CA2I3LJY.js +28 -0
- package/dist/server-ZA2N7MOP.js +28 -0
- package/dist/setup-HUYSMSBI.js +20 -0
- package/dist/setup-PT6WGOYB.js +20 -0
- package/dist/setup-VF4ZBLQQ.js +20 -0
- package/package.json +1 -1
- package/src/admin/routes.ts +24 -4
- package/src/auth/routes.ts +14 -11
- package/src/dashboard/app.js +8 -1
- package/src/engine/compliance.ts +2 -2
- package/src/server.ts +30 -0
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import "./chunk-KFQGP6VL.js";
|
|
2
|
+
|
|
3
|
+
// src/cli-serve.ts
|
|
4
|
+
import { existsSync, readFileSync } from "fs";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
import { homedir } from "os";
|
|
7
|
+
function loadEnvFile() {
|
|
8
|
+
const candidates = [
|
|
9
|
+
join(process.cwd(), ".env"),
|
|
10
|
+
join(homedir(), ".agenticmail", ".env")
|
|
11
|
+
];
|
|
12
|
+
for (const envPath of candidates) {
|
|
13
|
+
if (!existsSync(envPath)) continue;
|
|
14
|
+
try {
|
|
15
|
+
const content = readFileSync(envPath, "utf8");
|
|
16
|
+
for (const line of content.split("\n")) {
|
|
17
|
+
const trimmed = line.trim();
|
|
18
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
19
|
+
const eq = trimmed.indexOf("=");
|
|
20
|
+
if (eq < 0) continue;
|
|
21
|
+
const key = trimmed.slice(0, eq).trim();
|
|
22
|
+
let val = trimmed.slice(eq + 1).trim();
|
|
23
|
+
if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
|
|
24
|
+
val = val.slice(1, -1);
|
|
25
|
+
}
|
|
26
|
+
if (!process.env[key]) process.env[key] = val;
|
|
27
|
+
}
|
|
28
|
+
console.log(`Loaded config from ${envPath}`);
|
|
29
|
+
return;
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function ensureSecrets() {
|
|
35
|
+
const { randomUUID } = await import("crypto");
|
|
36
|
+
const envDir = join(homedir(), ".agenticmail");
|
|
37
|
+
const envPath = join(envDir, ".env");
|
|
38
|
+
let dirty = false;
|
|
39
|
+
if (!process.env.JWT_SECRET) {
|
|
40
|
+
process.env.JWT_SECRET = randomUUID() + randomUUID();
|
|
41
|
+
dirty = true;
|
|
42
|
+
console.log("[startup] Generated new JWT_SECRET (existing sessions will need to re-login)");
|
|
43
|
+
}
|
|
44
|
+
if (!process.env.AGENTICMAIL_VAULT_KEY) {
|
|
45
|
+
process.env.AGENTICMAIL_VAULT_KEY = randomUUID() + randomUUID();
|
|
46
|
+
dirty = true;
|
|
47
|
+
console.log("[startup] Generated new AGENTICMAIL_VAULT_KEY");
|
|
48
|
+
console.log("[startup] \u26A0\uFE0F Previously encrypted credentials will need to be re-entered in the dashboard");
|
|
49
|
+
}
|
|
50
|
+
if (dirty) {
|
|
51
|
+
try {
|
|
52
|
+
if (!existsSync(envDir)) {
|
|
53
|
+
const { mkdirSync } = await import("fs");
|
|
54
|
+
mkdirSync(envDir, { recursive: true });
|
|
55
|
+
}
|
|
56
|
+
const { appendFileSync } = await import("fs");
|
|
57
|
+
const lines = [];
|
|
58
|
+
let existing = "";
|
|
59
|
+
if (existsSync(envPath)) {
|
|
60
|
+
existing = readFileSync(envPath, "utf8");
|
|
61
|
+
}
|
|
62
|
+
if (!existing.includes("JWT_SECRET=")) {
|
|
63
|
+
lines.push(`JWT_SECRET=${process.env.JWT_SECRET}`);
|
|
64
|
+
}
|
|
65
|
+
if (!existing.includes("AGENTICMAIL_VAULT_KEY=")) {
|
|
66
|
+
lines.push(`AGENTICMAIL_VAULT_KEY=${process.env.AGENTICMAIL_VAULT_KEY}`);
|
|
67
|
+
}
|
|
68
|
+
if (lines.length) {
|
|
69
|
+
appendFileSync(envPath, "\n" + lines.join("\n") + "\n", { mode: 384 });
|
|
70
|
+
console.log(`[startup] Saved secrets to ${envPath}`);
|
|
71
|
+
}
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.warn(`[startup] Could not save secrets to ${envPath}: ${e.message}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function runServe(_args) {
|
|
78
|
+
loadEnvFile();
|
|
79
|
+
const DATABASE_URL = process.env.DATABASE_URL;
|
|
80
|
+
const PORT = parseInt(process.env.PORT || "8080", 10);
|
|
81
|
+
await ensureSecrets();
|
|
82
|
+
const JWT_SECRET = process.env.JWT_SECRET;
|
|
83
|
+
const VAULT_KEY = process.env.AGENTICMAIL_VAULT_KEY;
|
|
84
|
+
if (!DATABASE_URL) {
|
|
85
|
+
console.error("ERROR: DATABASE_URL is required.");
|
|
86
|
+
console.error("");
|
|
87
|
+
console.error("Set it via environment variable or .env file:");
|
|
88
|
+
console.error(" DATABASE_URL=postgresql://user:pass@host:5432/db npx @agenticmail/enterprise start");
|
|
89
|
+
console.error("");
|
|
90
|
+
console.error("Or create a .env file (in cwd or ~/.agenticmail/.env):");
|
|
91
|
+
console.error(" DATABASE_URL=postgresql://user:pass@host:5432/db");
|
|
92
|
+
console.error(" JWT_SECRET=your-secret-here");
|
|
93
|
+
console.error(" PORT=3200");
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
const { createAdapter } = await import("./factory-NUY5F26A.js");
|
|
97
|
+
const { createServer } = await import("./server-6JMYVJVM.js");
|
|
98
|
+
const db = await createAdapter({
|
|
99
|
+
type: DATABASE_URL.startsWith("postgres") ? "postgres" : "sqlite",
|
|
100
|
+
connectionString: DATABASE_URL
|
|
101
|
+
});
|
|
102
|
+
await db.migrate();
|
|
103
|
+
const server = createServer({
|
|
104
|
+
port: PORT,
|
|
105
|
+
db,
|
|
106
|
+
jwtSecret: JWT_SECRET,
|
|
107
|
+
corsOrigins: ["*"]
|
|
108
|
+
});
|
|
109
|
+
await server.start();
|
|
110
|
+
console.log(`AgenticMail Enterprise server running on :${PORT}`);
|
|
111
|
+
const tunnelToken = process.env.CLOUDFLARED_TOKEN;
|
|
112
|
+
if (tunnelToken) {
|
|
113
|
+
try {
|
|
114
|
+
const { execSync, spawn } = await import("child_process");
|
|
115
|
+
try {
|
|
116
|
+
execSync("which cloudflared", { timeout: 3e3 });
|
|
117
|
+
} catch {
|
|
118
|
+
console.log("[startup] cloudflared not found \u2014 skipping tunnel auto-start");
|
|
119
|
+
console.log("[startup] Install cloudflared to enable tunnel: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
execSync('pgrep -f "cloudflared.*tunnel.*run"', { timeout: 3e3 });
|
|
124
|
+
console.log("[startup] cloudflared tunnel already running");
|
|
125
|
+
return;
|
|
126
|
+
} catch {
|
|
127
|
+
}
|
|
128
|
+
const subdomain = process.env.AGENTICMAIL_SUBDOMAIN || process.env.AGENTICMAIL_DOMAIN || "";
|
|
129
|
+
console.log(`[startup] Starting cloudflared tunnel${subdomain ? ` for ${subdomain}.agenticmail.io` : ""}...`);
|
|
130
|
+
const child = spawn("cloudflared", ["tunnel", "--no-autoupdate", "run", "--token", tunnelToken], {
|
|
131
|
+
detached: true,
|
|
132
|
+
stdio: "ignore"
|
|
133
|
+
});
|
|
134
|
+
child.unref();
|
|
135
|
+
console.log("[startup] cloudflared tunnel started (pid " + child.pid + ")");
|
|
136
|
+
} catch (e) {
|
|
137
|
+
console.warn("[startup] Could not auto-start cloudflared: " + e.message);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
runServe
|
|
143
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import "./chunk-KFQGP6VL.js";
|
|
2
|
+
|
|
3
|
+
// src/cli-serve.ts
|
|
4
|
+
import { existsSync, readFileSync } from "fs";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
import { homedir } from "os";
|
|
7
|
+
function loadEnvFile() {
|
|
8
|
+
const candidates = [
|
|
9
|
+
join(process.cwd(), ".env"),
|
|
10
|
+
join(homedir(), ".agenticmail", ".env")
|
|
11
|
+
];
|
|
12
|
+
for (const envPath of candidates) {
|
|
13
|
+
if (!existsSync(envPath)) continue;
|
|
14
|
+
try {
|
|
15
|
+
const content = readFileSync(envPath, "utf8");
|
|
16
|
+
for (const line of content.split("\n")) {
|
|
17
|
+
const trimmed = line.trim();
|
|
18
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
19
|
+
const eq = trimmed.indexOf("=");
|
|
20
|
+
if (eq < 0) continue;
|
|
21
|
+
const key = trimmed.slice(0, eq).trim();
|
|
22
|
+
let val = trimmed.slice(eq + 1).trim();
|
|
23
|
+
if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
|
|
24
|
+
val = val.slice(1, -1);
|
|
25
|
+
}
|
|
26
|
+
if (!process.env[key]) process.env[key] = val;
|
|
27
|
+
}
|
|
28
|
+
console.log(`Loaded config from ${envPath}`);
|
|
29
|
+
return;
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function ensureSecrets() {
|
|
35
|
+
const { randomUUID } = await import("crypto");
|
|
36
|
+
const envDir = join(homedir(), ".agenticmail");
|
|
37
|
+
const envPath = join(envDir, ".env");
|
|
38
|
+
let dirty = false;
|
|
39
|
+
if (!process.env.JWT_SECRET) {
|
|
40
|
+
process.env.JWT_SECRET = randomUUID() + randomUUID();
|
|
41
|
+
dirty = true;
|
|
42
|
+
console.log("[startup] Generated new JWT_SECRET (existing sessions will need to re-login)");
|
|
43
|
+
}
|
|
44
|
+
if (!process.env.AGENTICMAIL_VAULT_KEY) {
|
|
45
|
+
process.env.AGENTICMAIL_VAULT_KEY = randomUUID() + randomUUID();
|
|
46
|
+
dirty = true;
|
|
47
|
+
console.log("[startup] Generated new AGENTICMAIL_VAULT_KEY");
|
|
48
|
+
console.log("[startup] \u26A0\uFE0F Previously encrypted credentials will need to be re-entered in the dashboard");
|
|
49
|
+
}
|
|
50
|
+
if (dirty) {
|
|
51
|
+
try {
|
|
52
|
+
if (!existsSync(envDir)) {
|
|
53
|
+
const { mkdirSync } = await import("fs");
|
|
54
|
+
mkdirSync(envDir, { recursive: true });
|
|
55
|
+
}
|
|
56
|
+
const { appendFileSync } = await import("fs");
|
|
57
|
+
const lines = [];
|
|
58
|
+
let existing = "";
|
|
59
|
+
if (existsSync(envPath)) {
|
|
60
|
+
existing = readFileSync(envPath, "utf8");
|
|
61
|
+
}
|
|
62
|
+
if (!existing.includes("JWT_SECRET=")) {
|
|
63
|
+
lines.push(`JWT_SECRET=${process.env.JWT_SECRET}`);
|
|
64
|
+
}
|
|
65
|
+
if (!existing.includes("AGENTICMAIL_VAULT_KEY=")) {
|
|
66
|
+
lines.push(`AGENTICMAIL_VAULT_KEY=${process.env.AGENTICMAIL_VAULT_KEY}`);
|
|
67
|
+
}
|
|
68
|
+
if (lines.length) {
|
|
69
|
+
appendFileSync(envPath, "\n" + lines.join("\n") + "\n", { mode: 384 });
|
|
70
|
+
console.log(`[startup] Saved secrets to ${envPath}`);
|
|
71
|
+
}
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.warn(`[startup] Could not save secrets to ${envPath}: ${e.message}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function runServe(_args) {
|
|
78
|
+
loadEnvFile();
|
|
79
|
+
const DATABASE_URL = process.env.DATABASE_URL;
|
|
80
|
+
const PORT = parseInt(process.env.PORT || "8080", 10);
|
|
81
|
+
await ensureSecrets();
|
|
82
|
+
const JWT_SECRET = process.env.JWT_SECRET;
|
|
83
|
+
const VAULT_KEY = process.env.AGENTICMAIL_VAULT_KEY;
|
|
84
|
+
if (!DATABASE_URL) {
|
|
85
|
+
console.error("ERROR: DATABASE_URL is required.");
|
|
86
|
+
console.error("");
|
|
87
|
+
console.error("Set it via environment variable or .env file:");
|
|
88
|
+
console.error(" DATABASE_URL=postgresql://user:pass@host:5432/db npx @agenticmail/enterprise start");
|
|
89
|
+
console.error("");
|
|
90
|
+
console.error("Or create a .env file (in cwd or ~/.agenticmail/.env):");
|
|
91
|
+
console.error(" DATABASE_URL=postgresql://user:pass@host:5432/db");
|
|
92
|
+
console.error(" JWT_SECRET=your-secret-here");
|
|
93
|
+
console.error(" PORT=3200");
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
const { createAdapter } = await import("./factory-NUY5F26A.js");
|
|
97
|
+
const { createServer } = await import("./server-CA2I3LJY.js");
|
|
98
|
+
const db = await createAdapter({
|
|
99
|
+
type: DATABASE_URL.startsWith("postgres") ? "postgres" : "sqlite",
|
|
100
|
+
connectionString: DATABASE_URL
|
|
101
|
+
});
|
|
102
|
+
await db.migrate();
|
|
103
|
+
const server = createServer({
|
|
104
|
+
port: PORT,
|
|
105
|
+
db,
|
|
106
|
+
jwtSecret: JWT_SECRET,
|
|
107
|
+
corsOrigins: ["*"]
|
|
108
|
+
});
|
|
109
|
+
await server.start();
|
|
110
|
+
console.log(`AgenticMail Enterprise server running on :${PORT}`);
|
|
111
|
+
const tunnelToken = process.env.CLOUDFLARED_TOKEN;
|
|
112
|
+
if (tunnelToken) {
|
|
113
|
+
try {
|
|
114
|
+
const { execSync, spawn } = await import("child_process");
|
|
115
|
+
try {
|
|
116
|
+
execSync("which cloudflared", { timeout: 3e3 });
|
|
117
|
+
} catch {
|
|
118
|
+
console.log("[startup] cloudflared not found \u2014 skipping tunnel auto-start");
|
|
119
|
+
console.log("[startup] Install cloudflared to enable tunnel: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
execSync('pgrep -f "cloudflared.*tunnel.*run"', { timeout: 3e3 });
|
|
124
|
+
console.log("[startup] cloudflared tunnel already running");
|
|
125
|
+
return;
|
|
126
|
+
} catch {
|
|
127
|
+
}
|
|
128
|
+
const subdomain = process.env.AGENTICMAIL_SUBDOMAIN || process.env.AGENTICMAIL_DOMAIN || "";
|
|
129
|
+
console.log(`[startup] Starting cloudflared tunnel${subdomain ? ` for ${subdomain}.agenticmail.io` : ""}...`);
|
|
130
|
+
const child = spawn("cloudflared", ["tunnel", "--no-autoupdate", "run", "--token", tunnelToken], {
|
|
131
|
+
detached: true,
|
|
132
|
+
stdio: "ignore"
|
|
133
|
+
});
|
|
134
|
+
child.unref();
|
|
135
|
+
console.log("[startup] cloudflared tunnel started (pid " + child.pid + ")");
|
|
136
|
+
} catch (e) {
|
|
137
|
+
console.warn("[startup] Could not auto-start cloudflared: " + e.message);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
runServe
|
|
143
|
+
};
|
|
@@ -0,0 +1,143 @@
|
|
|
1
|
+
import "./chunk-KFQGP6VL.js";
|
|
2
|
+
|
|
3
|
+
// src/cli-serve.ts
|
|
4
|
+
import { existsSync, readFileSync } from "fs";
|
|
5
|
+
import { join } from "path";
|
|
6
|
+
import { homedir } from "os";
|
|
7
|
+
function loadEnvFile() {
|
|
8
|
+
const candidates = [
|
|
9
|
+
join(process.cwd(), ".env"),
|
|
10
|
+
join(homedir(), ".agenticmail", ".env")
|
|
11
|
+
];
|
|
12
|
+
for (const envPath of candidates) {
|
|
13
|
+
if (!existsSync(envPath)) continue;
|
|
14
|
+
try {
|
|
15
|
+
const content = readFileSync(envPath, "utf8");
|
|
16
|
+
for (const line of content.split("\n")) {
|
|
17
|
+
const trimmed = line.trim();
|
|
18
|
+
if (!trimmed || trimmed.startsWith("#")) continue;
|
|
19
|
+
const eq = trimmed.indexOf("=");
|
|
20
|
+
if (eq < 0) continue;
|
|
21
|
+
const key = trimmed.slice(0, eq).trim();
|
|
22
|
+
let val = trimmed.slice(eq + 1).trim();
|
|
23
|
+
if (val.startsWith('"') && val.endsWith('"') || val.startsWith("'") && val.endsWith("'")) {
|
|
24
|
+
val = val.slice(1, -1);
|
|
25
|
+
}
|
|
26
|
+
if (!process.env[key]) process.env[key] = val;
|
|
27
|
+
}
|
|
28
|
+
console.log(`Loaded config from ${envPath}`);
|
|
29
|
+
return;
|
|
30
|
+
} catch {
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
async function ensureSecrets() {
|
|
35
|
+
const { randomUUID } = await import("crypto");
|
|
36
|
+
const envDir = join(homedir(), ".agenticmail");
|
|
37
|
+
const envPath = join(envDir, ".env");
|
|
38
|
+
let dirty = false;
|
|
39
|
+
if (!process.env.JWT_SECRET) {
|
|
40
|
+
process.env.JWT_SECRET = randomUUID() + randomUUID();
|
|
41
|
+
dirty = true;
|
|
42
|
+
console.log("[startup] Generated new JWT_SECRET (existing sessions will need to re-login)");
|
|
43
|
+
}
|
|
44
|
+
if (!process.env.AGENTICMAIL_VAULT_KEY) {
|
|
45
|
+
process.env.AGENTICMAIL_VAULT_KEY = randomUUID() + randomUUID();
|
|
46
|
+
dirty = true;
|
|
47
|
+
console.log("[startup] Generated new AGENTICMAIL_VAULT_KEY");
|
|
48
|
+
console.log("[startup] \u26A0\uFE0F Previously encrypted credentials will need to be re-entered in the dashboard");
|
|
49
|
+
}
|
|
50
|
+
if (dirty) {
|
|
51
|
+
try {
|
|
52
|
+
if (!existsSync(envDir)) {
|
|
53
|
+
const { mkdirSync } = await import("fs");
|
|
54
|
+
mkdirSync(envDir, { recursive: true });
|
|
55
|
+
}
|
|
56
|
+
const { appendFileSync } = await import("fs");
|
|
57
|
+
const lines = [];
|
|
58
|
+
let existing = "";
|
|
59
|
+
if (existsSync(envPath)) {
|
|
60
|
+
existing = readFileSync(envPath, "utf8");
|
|
61
|
+
}
|
|
62
|
+
if (!existing.includes("JWT_SECRET=")) {
|
|
63
|
+
lines.push(`JWT_SECRET=${process.env.JWT_SECRET}`);
|
|
64
|
+
}
|
|
65
|
+
if (!existing.includes("AGENTICMAIL_VAULT_KEY=")) {
|
|
66
|
+
lines.push(`AGENTICMAIL_VAULT_KEY=${process.env.AGENTICMAIL_VAULT_KEY}`);
|
|
67
|
+
}
|
|
68
|
+
if (lines.length) {
|
|
69
|
+
appendFileSync(envPath, "\n" + lines.join("\n") + "\n", { mode: 384 });
|
|
70
|
+
console.log(`[startup] Saved secrets to ${envPath}`);
|
|
71
|
+
}
|
|
72
|
+
} catch (e) {
|
|
73
|
+
console.warn(`[startup] Could not save secrets to ${envPath}: ${e.message}`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
async function runServe(_args) {
|
|
78
|
+
loadEnvFile();
|
|
79
|
+
const DATABASE_URL = process.env.DATABASE_URL;
|
|
80
|
+
const PORT = parseInt(process.env.PORT || "8080", 10);
|
|
81
|
+
await ensureSecrets();
|
|
82
|
+
const JWT_SECRET = process.env.JWT_SECRET;
|
|
83
|
+
const VAULT_KEY = process.env.AGENTICMAIL_VAULT_KEY;
|
|
84
|
+
if (!DATABASE_URL) {
|
|
85
|
+
console.error("ERROR: DATABASE_URL is required.");
|
|
86
|
+
console.error("");
|
|
87
|
+
console.error("Set it via environment variable or .env file:");
|
|
88
|
+
console.error(" DATABASE_URL=postgresql://user:pass@host:5432/db npx @agenticmail/enterprise start");
|
|
89
|
+
console.error("");
|
|
90
|
+
console.error("Or create a .env file (in cwd or ~/.agenticmail/.env):");
|
|
91
|
+
console.error(" DATABASE_URL=postgresql://user:pass@host:5432/db");
|
|
92
|
+
console.error(" JWT_SECRET=your-secret-here");
|
|
93
|
+
console.error(" PORT=3200");
|
|
94
|
+
process.exit(1);
|
|
95
|
+
}
|
|
96
|
+
const { createAdapter } = await import("./factory-NUY5F26A.js");
|
|
97
|
+
const { createServer } = await import("./server-ZA2N7MOP.js");
|
|
98
|
+
const db = await createAdapter({
|
|
99
|
+
type: DATABASE_URL.startsWith("postgres") ? "postgres" : "sqlite",
|
|
100
|
+
connectionString: DATABASE_URL
|
|
101
|
+
});
|
|
102
|
+
await db.migrate();
|
|
103
|
+
const server = createServer({
|
|
104
|
+
port: PORT,
|
|
105
|
+
db,
|
|
106
|
+
jwtSecret: JWT_SECRET,
|
|
107
|
+
corsOrigins: ["*"]
|
|
108
|
+
});
|
|
109
|
+
await server.start();
|
|
110
|
+
console.log(`AgenticMail Enterprise server running on :${PORT}`);
|
|
111
|
+
const tunnelToken = process.env.CLOUDFLARED_TOKEN;
|
|
112
|
+
if (tunnelToken) {
|
|
113
|
+
try {
|
|
114
|
+
const { execSync, spawn } = await import("child_process");
|
|
115
|
+
try {
|
|
116
|
+
execSync("which cloudflared", { timeout: 3e3 });
|
|
117
|
+
} catch {
|
|
118
|
+
console.log("[startup] cloudflared not found \u2014 skipping tunnel auto-start");
|
|
119
|
+
console.log("[startup] Install cloudflared to enable tunnel: https://developers.cloudflare.com/cloudflare-one/connections/connect-networks/downloads/");
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
execSync('pgrep -f "cloudflared.*tunnel.*run"', { timeout: 3e3 });
|
|
124
|
+
console.log("[startup] cloudflared tunnel already running");
|
|
125
|
+
return;
|
|
126
|
+
} catch {
|
|
127
|
+
}
|
|
128
|
+
const subdomain = process.env.AGENTICMAIL_SUBDOMAIN || process.env.AGENTICMAIL_DOMAIN || "";
|
|
129
|
+
console.log(`[startup] Starting cloudflared tunnel${subdomain ? ` for ${subdomain}.agenticmail.io` : ""}...`);
|
|
130
|
+
const child = spawn("cloudflared", ["tunnel", "--no-autoupdate", "run", "--token", tunnelToken], {
|
|
131
|
+
detached: true,
|
|
132
|
+
stdio: "ignore"
|
|
133
|
+
});
|
|
134
|
+
child.unref();
|
|
135
|
+
console.log("[startup] cloudflared tunnel started (pid " + child.pid + ")");
|
|
136
|
+
} catch (e) {
|
|
137
|
+
console.warn("[startup] Could not auto-start cloudflared: " + e.message);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
export {
|
|
142
|
+
runServe
|
|
143
|
+
};
|
package/dist/cli.js
CHANGED
|
@@ -57,14 +57,14 @@ Skill Development:
|
|
|
57
57
|
break;
|
|
58
58
|
case "serve":
|
|
59
59
|
case "start":
|
|
60
|
-
import("./cli-serve-
|
|
60
|
+
import("./cli-serve-FE4CMMSN.js").then((m) => m.runServe(args.slice(1))).catch(fatal);
|
|
61
61
|
break;
|
|
62
62
|
case "agent":
|
|
63
|
-
import("./cli-agent-
|
|
63
|
+
import("./cli-agent-EV7RDHZ4.js").then((m) => m.runAgent(args.slice(1))).catch(fatal);
|
|
64
64
|
break;
|
|
65
65
|
case "setup":
|
|
66
66
|
default:
|
|
67
|
-
import("./setup-
|
|
67
|
+
import("./setup-PT6WGOYB.js").then((m) => m.runSetupWizard()).catch(fatal);
|
|
68
68
|
break;
|
|
69
69
|
}
|
|
70
70
|
function fatal(err) {
|
package/dist/dashboard/app.js
CHANGED
|
@@ -163,6 +163,12 @@ function App() {
|
|
|
163
163
|
if (document.cookie.match(/em_session|em_csrf/)) {
|
|
164
164
|
authCall('/me').then(async d => {
|
|
165
165
|
setUser(d.user || d);
|
|
166
|
+
// If user is org-bound, lock org context immediately
|
|
167
|
+
var u = d.user || d;
|
|
168
|
+
if (u.clientOrgId) {
|
|
169
|
+
setSelectedOrgId(u.clientOrgId);
|
|
170
|
+
localStorage.setItem('em_client_org_id', u.clientOrgId);
|
|
171
|
+
}
|
|
166
172
|
// Init transport encryption BEFORE setting authed — ensures all subsequent
|
|
167
173
|
// API calls from child components are encrypted
|
|
168
174
|
try {
|
|
@@ -202,9 +208,10 @@ function App() {
|
|
|
202
208
|
apiCall('/settings').then(d => { const s = d.settings || d || {}; if (s.primaryColor) applyBrandColor(s.primaryColor); if (s.orgId) setOrgId(s.orgId); }).catch(() => {});
|
|
203
209
|
apiCall('/me/permissions').then(d => {
|
|
204
210
|
if (d && d.permissions) setPermissions(d.permissions);
|
|
205
|
-
// If user is assigned to a client org, auto-set org context
|
|
211
|
+
// If user is assigned to a client org, auto-set org context and lock switcher
|
|
206
212
|
if (d && d.clientOrgId) {
|
|
207
213
|
localStorage.setItem('em_client_org_id', d.clientOrgId);
|
|
214
|
+
setSelectedOrgId(d.clientOrgId);
|
|
208
215
|
} else {
|
|
209
216
|
localStorage.removeItem('em_client_org_id');
|
|
210
217
|
}
|
package/dist/index.js
CHANGED
|
@@ -7,7 +7,7 @@ import {
|
|
|
7
7
|
import {
|
|
8
8
|
provision,
|
|
9
9
|
runSetupWizard
|
|
10
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-OPOBUYJT.js";
|
|
11
11
|
import {
|
|
12
12
|
AgenticMailManager,
|
|
13
13
|
GoogleEmailProvider,
|
|
@@ -28,7 +28,7 @@ import {
|
|
|
28
28
|
executeTool,
|
|
29
29
|
runAgentLoop,
|
|
30
30
|
toolsToDefinitions
|
|
31
|
-
} from "./chunk-
|
|
31
|
+
} from "./chunk-FNUFLQJ3.js";
|
|
32
32
|
import {
|
|
33
33
|
ValidationError,
|
|
34
34
|
auditLogger,
|
|
@@ -42,7 +42,7 @@ import {
|
|
|
42
42
|
requireRole,
|
|
43
43
|
securityHeaders,
|
|
44
44
|
validate
|
|
45
|
-
} from "./chunk-
|
|
45
|
+
} from "./chunk-Y2KIY4BA.js";
|
|
46
46
|
import "./chunk-DJBCRQTD.js";
|
|
47
47
|
import {
|
|
48
48
|
PROVIDER_REGISTRY,
|
|
@@ -92,7 +92,7 @@ import {
|
|
|
92
92
|
init_storage_manager,
|
|
93
93
|
init_tenant,
|
|
94
94
|
init_workforce
|
|
95
|
-
} from "./chunk-
|
|
95
|
+
} from "./chunk-EKMS2KSE.js";
|
|
96
96
|
import {
|
|
97
97
|
AgentMemoryManager,
|
|
98
98
|
init_agent_memory
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
activity,
|
|
3
|
+
agentStatus,
|
|
4
|
+
approvals,
|
|
5
|
+
commBus,
|
|
6
|
+
communityRegistry,
|
|
7
|
+
compliance,
|
|
8
|
+
configGen,
|
|
9
|
+
databaseManager,
|
|
10
|
+
deployer,
|
|
11
|
+
dlp,
|
|
12
|
+
engine,
|
|
13
|
+
getChatPoller,
|
|
14
|
+
getEmailPoller,
|
|
15
|
+
getMessagingPoller,
|
|
16
|
+
guardrails,
|
|
17
|
+
hierarchyManager,
|
|
18
|
+
init_routes,
|
|
19
|
+
journal,
|
|
20
|
+
knowledgeBase,
|
|
21
|
+
knowledgeContribution,
|
|
22
|
+
lifecycle,
|
|
23
|
+
memoryManager,
|
|
24
|
+
mountRuntimeApp,
|
|
25
|
+
onboarding,
|
|
26
|
+
orgIntegrations,
|
|
27
|
+
permissionEngine,
|
|
28
|
+
policyEngine,
|
|
29
|
+
policyImporter,
|
|
30
|
+
setEngineDb,
|
|
31
|
+
setRuntime,
|
|
32
|
+
skillUpdater,
|
|
33
|
+
storageManager,
|
|
34
|
+
tenants,
|
|
35
|
+
vault,
|
|
36
|
+
workforce
|
|
37
|
+
} from "./chunk-HZZPIICV.js";
|
|
38
|
+
import "./chunk-VSBC4SWO.js";
|
|
39
|
+
import "./chunk-AF3WSNVX.js";
|
|
40
|
+
import "./chunk-74ZCQKYU.js";
|
|
41
|
+
import "./chunk-MOGIJA6K.js";
|
|
42
|
+
import "./chunk-C6JP5NR6.js";
|
|
43
|
+
import "./chunk-M6ZIC5H3.js";
|
|
44
|
+
import "./chunk-PWWV2U5P.js";
|
|
45
|
+
import "./chunk-MXK7RLTF.js";
|
|
46
|
+
import "./chunk-3FMK32KQ.js";
|
|
47
|
+
import "./chunk-Z7NVD3OQ.js";
|
|
48
|
+
import "./chunk-YDD5TC5Q.js";
|
|
49
|
+
import "./chunk-JGEVQZDR.js";
|
|
50
|
+
import "./chunk-WUAWWKTN.js";
|
|
51
|
+
import "./chunk-HS5YWSGM.js";
|
|
52
|
+
import "./chunk-22U7TZPN.js";
|
|
53
|
+
import "./chunk-KFQGP6VL.js";
|
|
54
|
+
init_routes();
|
|
55
|
+
export {
|
|
56
|
+
activity,
|
|
57
|
+
agentStatus,
|
|
58
|
+
approvals,
|
|
59
|
+
commBus,
|
|
60
|
+
communityRegistry,
|
|
61
|
+
compliance,
|
|
62
|
+
configGen,
|
|
63
|
+
databaseManager,
|
|
64
|
+
deployer,
|
|
65
|
+
dlp,
|
|
66
|
+
engine as engineRoutes,
|
|
67
|
+
getChatPoller,
|
|
68
|
+
getEmailPoller,
|
|
69
|
+
getMessagingPoller,
|
|
70
|
+
guardrails,
|
|
71
|
+
hierarchyManager,
|
|
72
|
+
journal,
|
|
73
|
+
knowledgeBase,
|
|
74
|
+
knowledgeContribution,
|
|
75
|
+
lifecycle,
|
|
76
|
+
memoryManager,
|
|
77
|
+
mountRuntimeApp,
|
|
78
|
+
onboarding,
|
|
79
|
+
orgIntegrations,
|
|
80
|
+
permissionEngine,
|
|
81
|
+
policyEngine,
|
|
82
|
+
policyImporter,
|
|
83
|
+
setEngineDb,
|
|
84
|
+
setRuntime,
|
|
85
|
+
skillUpdater,
|
|
86
|
+
storageManager,
|
|
87
|
+
tenants,
|
|
88
|
+
vault,
|
|
89
|
+
workforce
|
|
90
|
+
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import {
|
|
2
|
+
activity,
|
|
3
|
+
agentStatus,
|
|
4
|
+
approvals,
|
|
5
|
+
commBus,
|
|
6
|
+
communityRegistry,
|
|
7
|
+
compliance,
|
|
8
|
+
configGen,
|
|
9
|
+
databaseManager,
|
|
10
|
+
deployer,
|
|
11
|
+
dlp,
|
|
12
|
+
engine,
|
|
13
|
+
getChatPoller,
|
|
14
|
+
getEmailPoller,
|
|
15
|
+
getMessagingPoller,
|
|
16
|
+
guardrails,
|
|
17
|
+
hierarchyManager,
|
|
18
|
+
init_routes,
|
|
19
|
+
journal,
|
|
20
|
+
knowledgeBase,
|
|
21
|
+
knowledgeContribution,
|
|
22
|
+
lifecycle,
|
|
23
|
+
memoryManager,
|
|
24
|
+
mountRuntimeApp,
|
|
25
|
+
onboarding,
|
|
26
|
+
orgIntegrations,
|
|
27
|
+
permissionEngine,
|
|
28
|
+
policyEngine,
|
|
29
|
+
policyImporter,
|
|
30
|
+
setEngineDb,
|
|
31
|
+
setRuntime,
|
|
32
|
+
skillUpdater,
|
|
33
|
+
storageManager,
|
|
34
|
+
tenants,
|
|
35
|
+
vault,
|
|
36
|
+
workforce
|
|
37
|
+
} from "./chunk-EKMS2KSE.js";
|
|
38
|
+
import "./chunk-VSBC4SWO.js";
|
|
39
|
+
import "./chunk-AF3WSNVX.js";
|
|
40
|
+
import "./chunk-74ZCQKYU.js";
|
|
41
|
+
import "./chunk-MOGIJA6K.js";
|
|
42
|
+
import "./chunk-C6JP5NR6.js";
|
|
43
|
+
import "./chunk-M6ZIC5H3.js";
|
|
44
|
+
import "./chunk-PWWV2U5P.js";
|
|
45
|
+
import "./chunk-MXK7RLTF.js";
|
|
46
|
+
import "./chunk-3FMK32KQ.js";
|
|
47
|
+
import "./chunk-Z7NVD3OQ.js";
|
|
48
|
+
import "./chunk-YDD5TC5Q.js";
|
|
49
|
+
import "./chunk-JGEVQZDR.js";
|
|
50
|
+
import "./chunk-WUAWWKTN.js";
|
|
51
|
+
import "./chunk-HS5YWSGM.js";
|
|
52
|
+
import "./chunk-22U7TZPN.js";
|
|
53
|
+
import "./chunk-KFQGP6VL.js";
|
|
54
|
+
init_routes();
|
|
55
|
+
export {
|
|
56
|
+
activity,
|
|
57
|
+
agentStatus,
|
|
58
|
+
approvals,
|
|
59
|
+
commBus,
|
|
60
|
+
communityRegistry,
|
|
61
|
+
compliance,
|
|
62
|
+
configGen,
|
|
63
|
+
databaseManager,
|
|
64
|
+
deployer,
|
|
65
|
+
dlp,
|
|
66
|
+
engine as engineRoutes,
|
|
67
|
+
getChatPoller,
|
|
68
|
+
getEmailPoller,
|
|
69
|
+
getMessagingPoller,
|
|
70
|
+
guardrails,
|
|
71
|
+
hierarchyManager,
|
|
72
|
+
journal,
|
|
73
|
+
knowledgeBase,
|
|
74
|
+
knowledgeContribution,
|
|
75
|
+
lifecycle,
|
|
76
|
+
memoryManager,
|
|
77
|
+
mountRuntimeApp,
|
|
78
|
+
onboarding,
|
|
79
|
+
orgIntegrations,
|
|
80
|
+
permissionEngine,
|
|
81
|
+
policyEngine,
|
|
82
|
+
policyImporter,
|
|
83
|
+
setEngineDb,
|
|
84
|
+
setRuntime,
|
|
85
|
+
skillUpdater,
|
|
86
|
+
storageManager,
|
|
87
|
+
tenants,
|
|
88
|
+
vault,
|
|
89
|
+
workforce
|
|
90
|
+
};
|