@agenticmail/enterprise 0.5.342 → 0.5.344
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/{chunk-2DE62O56.js → chunk-AA6OVVQD.js} +107 -23
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/setup-4AS2ASES.js +20 -0
- package/dist/setup-KHWRJILU.js +20 -0
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
// src/setup/index.ts
|
|
6
6
|
import { execSync as execSync3 } from "child_process";
|
|
7
7
|
import { createRequire } from "module";
|
|
8
|
-
import { join as
|
|
8
|
+
import { join as join3 } from "path";
|
|
9
9
|
|
|
10
10
|
// src/setup/company.ts
|
|
11
11
|
function toSlug(name) {
|
|
@@ -713,8 +713,8 @@ async function runTunnelSetup(inquirer, chalk) {
|
|
|
713
713
|
console.log(chalk.yellow(" \u26A0 PM2 not available \u2014 tunnel started in background"));
|
|
714
714
|
console.log(chalk.dim(" Install PM2 for auto-restart: npm install -g pm2"));
|
|
715
715
|
try {
|
|
716
|
-
const { spawn } = await import("child_process");
|
|
717
|
-
const child =
|
|
716
|
+
const { spawn: spawn2 } = await import("child_process");
|
|
717
|
+
const child = spawn2("cloudflared", ["tunnel", "run"], { detached: true, stdio: "ignore" });
|
|
718
718
|
child.unref();
|
|
719
719
|
started = true;
|
|
720
720
|
} catch {
|
|
@@ -1045,7 +1045,9 @@ async function promptRegistration(inquirer, chalk, ora, domain, companyName, adm
|
|
|
1045
1045
|
|
|
1046
1046
|
// src/setup/provision.ts
|
|
1047
1047
|
import { randomUUID, randomBytes as randomBytes2 } from "crypto";
|
|
1048
|
-
import { execSync as execSync2 } from "child_process";
|
|
1048
|
+
import { execSync as execSync2, spawn } from "child_process";
|
|
1049
|
+
import { statSync } from "fs";
|
|
1050
|
+
import { join as join2 } from "path";
|
|
1049
1051
|
function generateOrgId() {
|
|
1050
1052
|
const chars = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
1051
1053
|
const bytes = randomBytes2(10);
|
|
@@ -1157,13 +1159,13 @@ async function provision(config, ora, chalk) {
|
|
|
1157
1159
|
spinner.succeed("Admin account created");
|
|
1158
1160
|
try {
|
|
1159
1161
|
const { writeFileSync: writeFileSync2, existsSync: existsSync2, mkdirSync } = await import("fs");
|
|
1160
|
-
const { join:
|
|
1162
|
+
const { join: join4 } = await import("path");
|
|
1161
1163
|
const { homedir: homedir2 } = await import("os");
|
|
1162
|
-
const envDir =
|
|
1164
|
+
const envDir = join4(homedir2(), ".agenticmail");
|
|
1163
1165
|
if (!existsSync2(envDir)) mkdirSync(envDir, { recursive: true });
|
|
1164
1166
|
const port = config.tunnel?.port || (config.deployTarget === "local" ? 3e3 : void 0) || (config.deployTarget === "docker" ? 3e3 : void 0) || 3200;
|
|
1165
1167
|
let existingEnv = "";
|
|
1166
|
-
const envFilePath =
|
|
1168
|
+
const envFilePath = join4(envDir, ".env");
|
|
1167
1169
|
if (existsSync2(envFilePath)) {
|
|
1168
1170
|
try {
|
|
1169
1171
|
existingEnv = (await import("fs")).readFileSync(envFilePath, "utf8");
|
|
@@ -1189,7 +1191,7 @@ async function provision(config, ora, chalk) {
|
|
|
1189
1191
|
"# BACK UP THIS FILE! You need it to recover on a new machine.",
|
|
1190
1192
|
...Array.from(envMap.entries()).map(([k, v]) => `${k}=${v}`)
|
|
1191
1193
|
].join("\n") + "\n";
|
|
1192
|
-
writeFileSync2(
|
|
1194
|
+
writeFileSync2(join4(envDir, ".env"), envContent, { mode: 384 });
|
|
1193
1195
|
spinner.succeed(`Config saved to ~/.agenticmail/.env`);
|
|
1194
1196
|
} catch {
|
|
1195
1197
|
}
|
|
@@ -1279,16 +1281,38 @@ async function deploy(config, db, jwtSecret, vaultKey, spinner, chalk) {
|
|
|
1279
1281
|
execSync2("pm2 delete enterprise 2>&1", { stdio: "pipe", timeout: 1e4 });
|
|
1280
1282
|
} catch {
|
|
1281
1283
|
}
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1284
|
+
let cfPath = "";
|
|
1285
|
+
try {
|
|
1286
|
+
const whichBin = process.platform === "win32" ? "where" : "which";
|
|
1287
|
+
cfPath = execSync2(`${whichBin} cloudflared`, { encoding: "utf8", timeout: 5e3 }).trim().split("\n")[0].trim();
|
|
1288
|
+
} catch {
|
|
1289
|
+
}
|
|
1290
|
+
if (!cfPath && process.platform === "win32") {
|
|
1291
|
+
const localAppData = process.env.LOCALAPPDATA || `${process.env.USERPROFILE}\\AppData\\Local`;
|
|
1292
|
+
const candidate = `${localAppData}\\cloudflared\\cloudflared.exe`;
|
|
1293
|
+
try {
|
|
1294
|
+
statSync(candidate);
|
|
1295
|
+
cfPath = candidate;
|
|
1296
|
+
} catch {
|
|
1297
|
+
}
|
|
1298
|
+
}
|
|
1299
|
+
if (!cfPath) throw new Error("cloudflared not found \u2014 install it first");
|
|
1300
|
+
execSync2(`pm2 start "${cfPath}" --name cloudflared --interpreter none -- tunnel --no-autoupdate run --token ${cloud.tunnelToken}`, { stdio: "pipe", timeout: 15e3 });
|
|
1301
|
+
let npxCmd = "npx";
|
|
1302
|
+
if (process.platform === "win32") {
|
|
1303
|
+
for (const candidate of [
|
|
1304
|
+
join2(process.env.APPDATA || "", "npm", "npx.cmd"),
|
|
1305
|
+
join2(process.env.ProgramFiles || "", "nodejs", "npx.cmd")
|
|
1306
|
+
]) {
|
|
1307
|
+
try {
|
|
1308
|
+
statSync(candidate);
|
|
1309
|
+
npxCmd = candidate;
|
|
1310
|
+
break;
|
|
1311
|
+
} catch {
|
|
1312
|
+
}
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
execSync2(`pm2 start "${npxCmd}" --name enterprise --interpreter none -- @agenticmail/enterprise start`, {
|
|
1292
1316
|
stdio: "pipe",
|
|
1293
1317
|
timeout: 15e3,
|
|
1294
1318
|
env: {
|
|
@@ -1300,6 +1324,12 @@ async function deploy(config, db, jwtSecret, vaultKey, spinner, chalk) {
|
|
|
1300
1324
|
AGENTICMAIL_DOMAIN: cloud.fqdn
|
|
1301
1325
|
}
|
|
1302
1326
|
});
|
|
1327
|
+
await new Promise((r) => setTimeout(r, 3e3));
|
|
1328
|
+
const jlist = execSync2("pm2 jlist", { encoding: "utf8", timeout: 1e4 });
|
|
1329
|
+
const procs = JSON.parse(jlist);
|
|
1330
|
+
const cfOnline = procs.find((p) => p.name === "cloudflared")?.pm2_env?.status === "online";
|
|
1331
|
+
const entOnline = procs.find((p) => p.name === "enterprise")?.pm2_env?.status === "online";
|
|
1332
|
+
if (!cfOnline || !entOnline) throw new Error(`cloudflared=${cfOnline ? "ok" : "down"}, enterprise=${entOnline ? "ok" : "down"}`);
|
|
1303
1333
|
try {
|
|
1304
1334
|
execSync2("pm2 save", { timeout: 1e4, stdio: "pipe" });
|
|
1305
1335
|
} catch {
|
|
@@ -1317,9 +1347,63 @@ async function deploy(config, db, jwtSecret, vaultKey, spinner, chalk) {
|
|
|
1317
1347
|
console.log(chalk.dim(" PM2 will auto-restart on crash and survive reboots."));
|
|
1318
1348
|
} catch (e) {
|
|
1319
1349
|
spinner.warn(`PM2 setup failed: ${e.message}`);
|
|
1320
|
-
console.log(
|
|
1321
|
-
|
|
1322
|
-
|
|
1350
|
+
console.log(chalk.dim(" Starting processes directly instead...\n"));
|
|
1351
|
+
let cfPath = "";
|
|
1352
|
+
try {
|
|
1353
|
+
const whichBin = process.platform === "win32" ? "where" : "which";
|
|
1354
|
+
cfPath = execSync2(`${whichBin} cloudflared`, { encoding: "utf8", timeout: 5e3 }).trim().split("\n")[0].trim();
|
|
1355
|
+
} catch {
|
|
1356
|
+
}
|
|
1357
|
+
if (!cfPath && process.platform === "win32") {
|
|
1358
|
+
const localAppData = process.env.LOCALAPPDATA || `${process.env.USERPROFILE}\\AppData\\Local`;
|
|
1359
|
+
const candidate = `${localAppData}\\cloudflared\\cloudflared.exe`;
|
|
1360
|
+
try {
|
|
1361
|
+
statSync(candidate);
|
|
1362
|
+
cfPath = candidate;
|
|
1363
|
+
} catch {
|
|
1364
|
+
}
|
|
1365
|
+
}
|
|
1366
|
+
const serverEnv = {
|
|
1367
|
+
...process.env,
|
|
1368
|
+
PORT: String(cloud.port || 8080),
|
|
1369
|
+
DATABASE_URL: database.connectionString || "",
|
|
1370
|
+
JWT_SECRET: jwtSecret,
|
|
1371
|
+
AGENTICMAIL_VAULT_KEY: vaultKey,
|
|
1372
|
+
AGENTICMAIL_DOMAIN: cloud.fqdn
|
|
1373
|
+
};
|
|
1374
|
+
if (cfPath) {
|
|
1375
|
+
const cfProc = spawn(cfPath, ["tunnel", "--no-autoupdate", "run", "--token", cloud.tunnelToken], {
|
|
1376
|
+
detached: true,
|
|
1377
|
+
stdio: "ignore",
|
|
1378
|
+
env: process.env
|
|
1379
|
+
});
|
|
1380
|
+
cfProc.unref();
|
|
1381
|
+
}
|
|
1382
|
+
let npxCmd = "npx";
|
|
1383
|
+
if (process.platform === "win32") {
|
|
1384
|
+
for (const candidate of [
|
|
1385
|
+
join2(process.env.APPDATA || "", "npm", "npx.cmd"),
|
|
1386
|
+
join2(process.env.ProgramFiles || "", "nodejs", "npx.cmd")
|
|
1387
|
+
]) {
|
|
1388
|
+
try {
|
|
1389
|
+
statSync(candidate);
|
|
1390
|
+
npxCmd = candidate;
|
|
1391
|
+
break;
|
|
1392
|
+
} catch {
|
|
1393
|
+
}
|
|
1394
|
+
}
|
|
1395
|
+
}
|
|
1396
|
+
const entProc = spawn(npxCmd, ["@agenticmail/enterprise", "start"], {
|
|
1397
|
+
detached: true,
|
|
1398
|
+
stdio: "ignore",
|
|
1399
|
+
env: serverEnv,
|
|
1400
|
+
shell: process.platform === "win32"
|
|
1401
|
+
});
|
|
1402
|
+
entProc.unref();
|
|
1403
|
+
await new Promise((r) => setTimeout(r, 5e3));
|
|
1404
|
+
spinner.succeed(`Live at https://${cloud.fqdn}`);
|
|
1405
|
+
console.log(chalk.yellow(" Note: Processes running in background. They will stop when you close this terminal."));
|
|
1406
|
+
console.log(chalk.dim(" For persistence, install PM2: npm install -g pm2"));
|
|
1323
1407
|
}
|
|
1324
1408
|
console.log("");
|
|
1325
1409
|
console.log(chalk.bold.green(" \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500"));
|
|
@@ -1499,7 +1583,7 @@ async function ensureDbDriver(dbType, ora, chalk) {
|
|
|
1499
1583
|
}
|
|
1500
1584
|
if (!found) {
|
|
1501
1585
|
try {
|
|
1502
|
-
const req = createRequire(
|
|
1586
|
+
const req = createRequire(join3(process.cwd(), "index.js"));
|
|
1503
1587
|
req.resolve(pkg);
|
|
1504
1588
|
found = true;
|
|
1505
1589
|
} catch {
|
|
@@ -1508,7 +1592,7 @@ async function ensureDbDriver(dbType, ora, chalk) {
|
|
|
1508
1592
|
if (!found) {
|
|
1509
1593
|
try {
|
|
1510
1594
|
const globalPrefix = execSync3("npm prefix -g", { encoding: "utf-8", stdio: ["pipe", "pipe", "pipe"] }).trim();
|
|
1511
|
-
const req = createRequire(
|
|
1595
|
+
const req = createRequire(join3(globalPrefix, "lib", "node_modules", ".package-lock.json"));
|
|
1512
1596
|
req.resolve(pkg);
|
|
1513
1597
|
found = true;
|
|
1514
1598
|
} catch {
|
package/dist/cli.js
CHANGED
package/dist/index.js
CHANGED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
promptCompanyInfo,
|
|
3
|
+
promptDatabase,
|
|
4
|
+
promptDeployment,
|
|
5
|
+
promptDomain,
|
|
6
|
+
promptRegistration,
|
|
7
|
+
provision,
|
|
8
|
+
runSetupWizard
|
|
9
|
+
} from "./chunk-AA6OVVQD.js";
|
|
10
|
+
import "./chunk-Z3I6GNTS.js";
|
|
11
|
+
import "./chunk-KFQGP6VL.js";
|
|
12
|
+
export {
|
|
13
|
+
promptCompanyInfo,
|
|
14
|
+
promptDatabase,
|
|
15
|
+
promptDeployment,
|
|
16
|
+
promptDomain,
|
|
17
|
+
promptRegistration,
|
|
18
|
+
provision,
|
|
19
|
+
runSetupWizard
|
|
20
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
promptCompanyInfo,
|
|
3
|
+
promptDatabase,
|
|
4
|
+
promptDeployment,
|
|
5
|
+
promptDomain,
|
|
6
|
+
promptRegistration,
|
|
7
|
+
provision,
|
|
8
|
+
runSetupWizard
|
|
9
|
+
} from "./chunk-FWGDL7KF.js";
|
|
10
|
+
import "./chunk-Z3I6GNTS.js";
|
|
11
|
+
import "./chunk-KFQGP6VL.js";
|
|
12
|
+
export {
|
|
13
|
+
promptCompanyInfo,
|
|
14
|
+
promptDatabase,
|
|
15
|
+
promptDeployment,
|
|
16
|
+
promptDomain,
|
|
17
|
+
promptRegistration,
|
|
18
|
+
provision,
|
|
19
|
+
runSetupWizard
|
|
20
|
+
};
|