@agenticmail/enterprise 0.5.193 → 0.5.195

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.
@@ -0,0 +1,69 @@
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 runServe(_args) {
35
+ loadEnvFile();
36
+ const DATABASE_URL = process.env.DATABASE_URL;
37
+ const JWT_SECRET = process.env.JWT_SECRET || "auto-" + Date.now();
38
+ const PORT = parseInt(process.env.PORT || "8080", 10);
39
+ if (!DATABASE_URL) {
40
+ console.error("ERROR: DATABASE_URL is required.");
41
+ console.error("");
42
+ console.error("Set it via environment variable or .env file:");
43
+ console.error(" DATABASE_URL=postgresql://user:pass@host:5432/db npx @agenticmail/enterprise start");
44
+ console.error("");
45
+ console.error("Or create a .env file (in cwd or ~/.agenticmail/.env):");
46
+ console.error(" DATABASE_URL=postgresql://user:pass@host:5432/db");
47
+ console.error(" JWT_SECRET=your-secret-here");
48
+ console.error(" PORT=3200");
49
+ process.exit(1);
50
+ }
51
+ const { createAdapter } = await import("./factory-K32DV2DR.js");
52
+ const { createServer } = await import("./server-P7UOPB2B.js");
53
+ const db = await createAdapter({
54
+ type: DATABASE_URL.startsWith("postgres") ? "postgres" : "sqlite",
55
+ connectionString: DATABASE_URL
56
+ });
57
+ await db.migrate();
58
+ const server = createServer({
59
+ port: PORT,
60
+ db,
61
+ jwtSecret: JWT_SECRET,
62
+ corsOrigins: ["*"]
63
+ });
64
+ await server.start();
65
+ console.log(`AgenticMail Enterprise server running on :${PORT}`);
66
+ }
67
+ export {
68
+ runServe
69
+ };
package/dist/cli.js CHANGED
@@ -26,6 +26,7 @@ AgenticMail Enterprise CLI
26
26
 
27
27
  Commands:
28
28
  setup Interactive setup wizard (default)
29
+ start / serve Start the server (uses DATABASE_URL env)
29
30
  validate <path> Validate a community skill manifest
30
31
  --all Validate all skills in community-skills/
31
32
  --json Machine-readable output
@@ -51,14 +52,15 @@ Skill Development:
51
52
  `);
52
53
  break;
53
54
  case "serve":
54
- import("./cli-serve-OOXMWQUD.js").then((m) => m.runServe(args.slice(1))).catch(fatal);
55
+ case "start":
56
+ import("./cli-serve-4TOTP57F.js").then((m) => m.runServe(args.slice(1))).catch(fatal);
55
57
  break;
56
58
  case "agent":
57
59
  import("./cli-agent-XYXSRD2Q.js").then((m) => m.runAgent(args.slice(1))).catch(fatal);
58
60
  break;
59
61
  case "setup":
60
62
  default:
61
- import("./setup-GBVE3MRW.js").then((m) => m.runSetupWizard()).catch(fatal);
63
+ import("./setup-LVG72MU2.js").then((m) => m.runSetupWizard()).catch(fatal);
62
64
  break;
63
65
  }
64
66
  function fatal(err) {
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  provision,
9
9
  runSetupWizard
10
- } from "./chunk-2ZP3V7GQ.js";
10
+ } from "./chunk-MS2ELDV5.js";
11
11
  import {
12
12
  AgenticMailManager,
13
13
  GoogleEmailProvider,
@@ -0,0 +1,20 @@
1
+ import {
2
+ promptCompanyInfo,
3
+ promptDatabase,
4
+ promptDeployment,
5
+ promptDomain,
6
+ promptRegistration,
7
+ provision,
8
+ runSetupWizard
9
+ } from "./chunk-MS2ELDV5.js";
10
+ import "./chunk-VQQ4SYYQ.js";
11
+ import "./chunk-KFQGP6VL.js";
12
+ export {
13
+ promptCompanyInfo,
14
+ promptDatabase,
15
+ promptDeployment,
16
+ promptDomain,
17
+ promptRegistration,
18
+ provision,
19
+ runSetupWizard
20
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/enterprise",
3
- "version": "0.5.193",
3
+ "version": "0.5.195",
4
4
  "description": "AgenticMail Enterprise — cloud-hosted AI agent identity, email, auth & compliance for organizations",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli-serve.ts CHANGED
@@ -1,20 +1,67 @@
1
1
  /**
2
- * `npx @agenticmail/enterprise serve`
2
+ * `npx @agenticmail/enterprise serve` / `start`
3
3
  *
4
4
  * Starts the enterprise server headlessly (no interactive wizard).
5
+ * Auto-loads .env file from cwd or ~/.agenticmail/.env if present.
5
6
  * Reads configuration from environment variables:
6
7
  * DATABASE_URL — Postgres/SQLite connection string (required)
7
8
  * JWT_SECRET — JWT signing secret (required)
8
9
  * PORT — HTTP port (default: 8080)
9
10
  */
10
11
 
12
+ import { existsSync, readFileSync } from 'fs';
13
+ import { join } from 'path';
14
+ import { homedir } from 'os';
15
+
16
+ function loadEnvFile(): void {
17
+ // Try cwd first, then ~/.agenticmail/
18
+ const candidates = [
19
+ join(process.cwd(), '.env'),
20
+ join(homedir(), '.agenticmail', '.env'),
21
+ ];
22
+
23
+ for (const envPath of candidates) {
24
+ if (!existsSync(envPath)) continue;
25
+ try {
26
+ const content = readFileSync(envPath, 'utf8');
27
+ for (const line of content.split('\n')) {
28
+ const trimmed = line.trim();
29
+ if (!trimmed || trimmed.startsWith('#')) continue;
30
+ const eq = trimmed.indexOf('=');
31
+ if (eq < 0) continue;
32
+ const key = trimmed.slice(0, eq).trim();
33
+ let val = trimmed.slice(eq + 1).trim();
34
+ // Strip quotes
35
+ if ((val.startsWith('"') && val.endsWith('"')) || (val.startsWith("'") && val.endsWith("'"))) {
36
+ val = val.slice(1, -1);
37
+ }
38
+ if (!process.env[key]) process.env[key] = val;
39
+ }
40
+ console.log(`Loaded config from ${envPath}`);
41
+ return;
42
+ } catch { /* ignore */ }
43
+ }
44
+ }
45
+
11
46
  export async function runServe(_args: string[]) {
47
+ loadEnvFile();
48
+
12
49
  const DATABASE_URL = process.env.DATABASE_URL;
13
- const JWT_SECRET = process.env.JWT_SECRET;
50
+ const JWT_SECRET = process.env.JWT_SECRET || 'auto-' + Date.now();
14
51
  const PORT = parseInt(process.env.PORT || '8080', 10);
15
52
 
16
- if (!DATABASE_URL) { console.error('ERROR: DATABASE_URL environment variable is required'); process.exit(1); }
17
- if (!JWT_SECRET) { console.error('ERROR: JWT_SECRET environment variable is required'); process.exit(1); }
53
+ if (!DATABASE_URL) {
54
+ console.error('ERROR: DATABASE_URL is required.');
55
+ console.error('');
56
+ console.error('Set it via environment variable or .env file:');
57
+ console.error(' DATABASE_URL=postgresql://user:pass@host:5432/db npx @agenticmail/enterprise start');
58
+ console.error('');
59
+ console.error('Or create a .env file (in cwd or ~/.agenticmail/.env):');
60
+ console.error(' DATABASE_URL=postgresql://user:pass@host:5432/db');
61
+ console.error(' JWT_SECRET=your-secret-here');
62
+ console.error(' PORT=3200');
63
+ process.exit(1);
64
+ }
18
65
 
19
66
  const { createAdapter } = await import('./db/factory.js');
20
67
  const { createServer } = await import('./server.js');
package/src/cli.ts CHANGED
@@ -51,6 +51,7 @@ AgenticMail Enterprise CLI
51
51
 
52
52
  Commands:
53
53
  setup Interactive setup wizard (default)
54
+ start / serve Start the server (uses DATABASE_URL env)
54
55
  validate <path> Validate a community skill manifest
55
56
  --all Validate all skills in community-skills/
56
57
  --json Machine-readable output
@@ -77,6 +78,7 @@ Skill Development:
77
78
  break;
78
79
 
79
80
  case 'serve':
81
+ case 'start':
80
82
  import('./cli-serve.js').then(m => m.runServe(args.slice(1))).catch(fatal);
81
83
  break;
82
84
 
@@ -164,6 +164,24 @@ export async function provision(
164
164
  });
165
165
  spinner.succeed('Admin account created');
166
166
 
167
+ // ─── Save .env for restart ─────────────────────
168
+ try {
169
+ const { writeFileSync, existsSync, mkdirSync } = await import('fs');
170
+ const { join } = await import('path');
171
+ const { homedir } = await import('os');
172
+ const envDir = join(homedir(), '.agenticmail');
173
+ if (!existsSync(envDir)) mkdirSync(envDir, { recursive: true });
174
+ const envContent = [
175
+ '# AgenticMail Enterprise — auto-generated by setup wizard',
176
+ `DATABASE_URL=${config.database.connectionString || ''}`,
177
+ `JWT_SECRET=${jwtSecret}`,
178
+ `AGENTICMAIL_VAULT_KEY=${vaultKey}`,
179
+ `PORT=${config.tunnel?.port || 3200}`,
180
+ ].join('\n') + '\n';
181
+ writeFileSync(join(envDir, '.env'), envContent, { mode: 0o600 });
182
+ spinner.succeed(`Config saved to ~/.agenticmail/.env`);
183
+ } catch { /* non-critical */ }
184
+
167
185
  // ─── Deploy ────────────────────────────────────
168
186
  const result = await deploy(config, db, jwtSecret, vaultKey, spinner, chalk);
169
187