@agenticmail/enterprise 0.5.343 → 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-FWGDL7KF.js → chunk-AA6OVVQD.js} +88 -64
- package/dist/cli.js +1 -1
- package/dist/index.js +1 -1
- package/dist/setup-4AS2ASES.js +20 -0
- package/package.json +1 -1
- package/dist/chunk-2DE62O56.js +0 -1599
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
getSupportedDatabases
|
|
3
3
|
} from "./chunk-Z3I6GNTS.js";
|
|
4
|
-
import {
|
|
5
|
-
__require
|
|
6
|
-
} from "./chunk-KFQGP6VL.js";
|
|
7
4
|
|
|
8
5
|
// src/setup/index.ts
|
|
9
6
|
import { execSync as execSync3 } from "child_process";
|
|
@@ -262,8 +259,8 @@ async function promptDatabase(inquirer, chalk) {
|
|
|
262
259
|
import { execSync, exec as execCb } from "child_process";
|
|
263
260
|
import { promisify } from "util";
|
|
264
261
|
import { existsSync, writeFileSync, readFileSync } from "fs";
|
|
265
|
-
import { join
|
|
266
|
-
import { homedir
|
|
262
|
+
import { join } from "path";
|
|
263
|
+
import { homedir, platform, arch } from "os";
|
|
267
264
|
var execP = promisify(execCb);
|
|
268
265
|
function whichCmd(bin) {
|
|
269
266
|
const cmd = platform() === "win32" ? `where ${bin}` : `which ${bin}`;
|
|
@@ -488,7 +485,7 @@ async function runCloudSetup(inquirer, chalk, existingSubdomain) {
|
|
|
488
485
|
console.log(` ${chalk.cyan("npx @agenticmail/enterprise start")}`);
|
|
489
486
|
console.log("");
|
|
490
487
|
console.log(chalk.dim(" Or let the setup wizard start them with PM2 (next step).\n"));
|
|
491
|
-
const envPath =
|
|
488
|
+
const envPath = join(homedir(), ".agenticmail", ".env");
|
|
492
489
|
try {
|
|
493
490
|
let envContent = "";
|
|
494
491
|
if (existsSync(envPath)) {
|
|
@@ -508,7 +505,7 @@ CLOUDFLARED_TOKEN=${tunnelToken}
|
|
|
508
505
|
`;
|
|
509
506
|
}
|
|
510
507
|
const { mkdirSync } = await import("fs");
|
|
511
|
-
mkdirSync(
|
|
508
|
+
mkdirSync(join(homedir(), ".agenticmail"), { recursive: true });
|
|
512
509
|
writeFileSync(envPath, envContent, { mode: 384 });
|
|
513
510
|
} catch {
|
|
514
511
|
}
|
|
@@ -562,8 +559,8 @@ async function runTunnelSetup(inquirer, chalk) {
|
|
|
562
559
|
}
|
|
563
560
|
}
|
|
564
561
|
console.log(chalk.bold(" 2. Cloudflare Authentication"));
|
|
565
|
-
const cfDir =
|
|
566
|
-
const certPath =
|
|
562
|
+
const cfDir = join(homedir(), ".cloudflared");
|
|
563
|
+
const certPath = join(cfDir, "cert.pem");
|
|
567
564
|
const loggedIn = existsSync(certPath);
|
|
568
565
|
if (loggedIn) {
|
|
569
566
|
console.log(chalk.green(" \u2713 Already authenticated\n"));
|
|
@@ -644,14 +641,14 @@ async function runTunnelSetup(inquirer, chalk) {
|
|
|
644
641
|
}
|
|
645
642
|
const config = [
|
|
646
643
|
`tunnel: ${tunnelId}`,
|
|
647
|
-
`credentials-file: ${
|
|
644
|
+
`credentials-file: ${join(cfDir, tunnelId + ".json")}`,
|
|
648
645
|
"",
|
|
649
646
|
"ingress:",
|
|
650
647
|
` - hostname: ${domain}`,
|
|
651
648
|
` service: http://localhost:${port}`,
|
|
652
649
|
" - service: http_status:404"
|
|
653
650
|
].join("\n");
|
|
654
|
-
writeFileSync(
|
|
651
|
+
writeFileSync(join(cfDir, "config.yml"), config);
|
|
655
652
|
console.log(chalk.green(` \u2713 Config written: ${domain} \u2192 localhost:${port}`));
|
|
656
653
|
try {
|
|
657
654
|
execSync(`cloudflared tunnel route dns ${tunnelId} ${domain} 2>&1`, { encoding: "utf8", timeout: 3e4 });
|
|
@@ -716,8 +713,8 @@ async function runTunnelSetup(inquirer, chalk) {
|
|
|
716
713
|
console.log(chalk.yellow(" \u26A0 PM2 not available \u2014 tunnel started in background"));
|
|
717
714
|
console.log(chalk.dim(" Install PM2 for auto-restart: npm install -g pm2"));
|
|
718
715
|
try {
|
|
719
|
-
const { spawn } = await import("child_process");
|
|
720
|
-
const child =
|
|
716
|
+
const { spawn: spawn2 } = await import("child_process");
|
|
717
|
+
const child = spawn2("cloudflared", ["tunnel", "run"], { detached: true, stdio: "ignore" });
|
|
721
718
|
child.unref();
|
|
722
719
|
started = true;
|
|
723
720
|
} catch {
|
|
@@ -1048,7 +1045,9 @@ async function promptRegistration(inquirer, chalk, ora, domain, companyName, adm
|
|
|
1048
1045
|
|
|
1049
1046
|
// src/setup/provision.ts
|
|
1050
1047
|
import { randomUUID, randomBytes as randomBytes2 } from "crypto";
|
|
1051
|
-
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";
|
|
1052
1051
|
function generateOrgId() {
|
|
1053
1052
|
const chars = "ABCDEFGHJKLMNPQRSTUVWXYZ23456789";
|
|
1054
1053
|
const bytes = randomBytes2(10);
|
|
@@ -1161,8 +1160,8 @@ async function provision(config, ora, chalk) {
|
|
|
1161
1160
|
try {
|
|
1162
1161
|
const { writeFileSync: writeFileSync2, existsSync: existsSync2, mkdirSync } = await import("fs");
|
|
1163
1162
|
const { join: join4 } = await import("path");
|
|
1164
|
-
const { homedir:
|
|
1165
|
-
const envDir = join4(
|
|
1163
|
+
const { homedir: homedir2 } = await import("os");
|
|
1164
|
+
const envDir = join4(homedir2(), ".agenticmail");
|
|
1166
1165
|
if (!existsSync2(envDir)) mkdirSync(envDir, { recursive: true });
|
|
1167
1166
|
const port = config.tunnel?.port || (config.deployTarget === "local" ? 3e3 : void 0) || (config.deployTarget === "docker" ? 3e3 : void 0) || 3200;
|
|
1168
1167
|
let existingEnv = "";
|
|
@@ -1282,25 +1281,38 @@ async function deploy(config, db, jwtSecret, vaultKey, spinner, chalk) {
|
|
|
1282
1281
|
execSync2("pm2 delete enterprise 2>&1", { stdio: "pipe", timeout: 1e4 });
|
|
1283
1282
|
} catch {
|
|
1284
1283
|
}
|
|
1285
|
-
let cfPath = "
|
|
1284
|
+
let cfPath = "";
|
|
1286
1285
|
try {
|
|
1287
1286
|
const whichBin = process.platform === "win32" ? "where" : "which";
|
|
1288
1287
|
cfPath = execSync2(`${whichBin} cloudflared`, { encoding: "utf8", timeout: 5e3 }).trim().split("\n")[0].trim();
|
|
1289
1288
|
} catch {
|
|
1290
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");
|
|
1291
1300
|
execSync2(`pm2 start "${cfPath}" --name cloudflared --interpreter none -- tunnel --no-autoupdate run --token ${cloud.tunnelToken}`, { stdio: "pipe", timeout: 15e3 });
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
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
|
+
}
|
|
1302
1314
|
}
|
|
1303
|
-
execSync2(
|
|
1315
|
+
execSync2(`pm2 start "${npxCmd}" --name enterprise --interpreter none -- @agenticmail/enterprise start`, {
|
|
1304
1316
|
stdio: "pipe",
|
|
1305
1317
|
timeout: 15e3,
|
|
1306
1318
|
env: {
|
|
@@ -1313,20 +1325,11 @@ async function deploy(config, db, jwtSecret, vaultKey, spinner, chalk) {
|
|
|
1313
1325
|
}
|
|
1314
1326
|
});
|
|
1315
1327
|
await new Promise((r) => setTimeout(r, 3e3));
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
if (cfProc?.pm2_env?.status !== "online") {
|
|
1322
|
-
throw new Error("cloudflared not running");
|
|
1323
|
-
}
|
|
1324
|
-
if (entProc?.pm2_env?.status !== "online") {
|
|
1325
|
-
throw new Error("enterprise server not running");
|
|
1326
|
-
}
|
|
1327
|
-
} catch (verifyErr) {
|
|
1328
|
-
throw new Error(`Processes not healthy: ${verifyErr.message}`);
|
|
1329
|
-
}
|
|
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"}`);
|
|
1330
1333
|
try {
|
|
1331
1334
|
execSync2("pm2 save", { timeout: 1e4, stdio: "pipe" });
|
|
1332
1335
|
} catch {
|
|
@@ -1345,35 +1348,56 @@ async function deploy(config, db, jwtSecret, vaultKey, spinner, chalk) {
|
|
|
1345
1348
|
} catch (e) {
|
|
1346
1349
|
spinner.warn(`PM2 setup failed: ${e.message}`);
|
|
1347
1350
|
console.log(chalk.dim(" Starting processes directly instead...\n"));
|
|
1348
|
-
|
|
1349
|
-
let cfPath = "cloudflared";
|
|
1351
|
+
let cfPath = "";
|
|
1350
1352
|
try {
|
|
1351
1353
|
const whichBin = process.platform === "win32" ? "where" : "which";
|
|
1352
1354
|
cfPath = execSync2(`${whichBin} cloudflared`, { encoding: "utf8", timeout: 5e3 }).trim().split("\n")[0].trim();
|
|
1353
1355
|
} catch {
|
|
1354
1356
|
}
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
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"], {
|
|
1367
1397
|
detached: true,
|
|
1368
1398
|
stdio: "ignore",
|
|
1369
|
-
env:
|
|
1370
|
-
|
|
1371
|
-
PORT: String(cloud.port || 8080),
|
|
1372
|
-
DATABASE_URL: database.connectionString || "",
|
|
1373
|
-
JWT_SECRET: jwtSecret,
|
|
1374
|
-
AGENTICMAIL_VAULT_KEY: vaultKey,
|
|
1375
|
-
AGENTICMAIL_DOMAIN: cloud.fqdn
|
|
1376
|
-
}
|
|
1399
|
+
env: serverEnv,
|
|
1400
|
+
shell: process.platform === "win32"
|
|
1377
1401
|
});
|
|
1378
1402
|
entProc.unref();
|
|
1379
1403
|
await new Promise((r) => setTimeout(r, 5e3));
|
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
|
+
};
|