@agenticmail/enterprise 0.5.225 → 0.5.227

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,114 @@
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-K32DV2DR.js");
97
+ const { createServer } = await import("./server-E6O6EPPP.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
+ }
112
+ export {
113
+ runServe
114
+ };
package/dist/cli.js CHANGED
@@ -53,14 +53,14 @@ Skill Development:
53
53
  break;
54
54
  case "serve":
55
55
  case "start":
56
- import("./cli-serve-LNJZMBQU.js").then((m) => m.runServe(args.slice(1))).catch(fatal);
56
+ import("./cli-serve-BACNSSXS.js").then((m) => m.runServe(args.slice(1))).catch(fatal);
57
57
  break;
58
58
  case "agent":
59
- import("./cli-agent-JRAUHZUL.js").then((m) => m.runAgent(args.slice(1))).catch(fatal);
59
+ import("./cli-agent-5ZU3YHEY.js").then((m) => m.runAgent(args.slice(1))).catch(fatal);
60
60
  break;
61
61
  case "setup":
62
62
  default:
63
- import("./setup-N5RUFJ6B.js").then((m) => m.runSetupWizard()).catch(fatal);
63
+ import("./setup-EW5CRLLS.js").then((m) => m.runSetupWizard()).catch(fatal);
64
64
  break;
65
65
  }
66
66
  function fatal(err) {
@@ -55,23 +55,23 @@
55
55
  }
56
56
 
57
57
  [data-theme="light"] {
58
- --bg-primary: #f8f9fb;
59
- --bg-secondary: #ffffff;
60
- --bg-tertiary: #f1f3f8;
61
- --bg-hover: #e8ebf0;
62
- --bg-active: #dde1ea;
63
- --bg-card: #ffffff;
64
- --bg-input: #f1f3f8;
58
+ --bg-primary: #d0c5a0;
59
+ --bg-secondary: #ddd3b2;
60
+ --bg-tertiary: #c8bc94;
61
+ --bg-hover: #c0b488;
62
+ --bg-active: #b8ab7e;
63
+ --bg-card: #ddd3b2;
64
+ --bg-input: #c8bc94;
65
65
  --bg-modal: rgba(0,0,0,0.4);
66
- --border: #e2e5ed;
67
- --border-light: #eceef4;
68
- --text-primary: #111827;
69
- --text-secondary: #4b5563;
70
- --text-muted: #9ca3af;
66
+ --border: #b0a47a;
67
+ --border-light: #c4b890;
68
+ --text-primary: #2c2410;
69
+ --text-secondary: #4a3f28;
70
+ --text-muted: #7a6e50;
71
71
  --text-inverse: #ffffff;
72
- --shadow: 0 1px 3px rgba(0,0,0,0.08);
73
- --shadow-lg: 0 4px 12px rgba(0,0,0,0.1);
74
- --shadow-xl: 0 8px 24px rgba(0,0,0,0.12);
72
+ --shadow: 0 1px 3px rgba(44,36,16,0.12);
73
+ --shadow-lg: 0 4px 12px rgba(44,36,16,0.15);
74
+ --shadow-xl: 0 8px 24px rgba(44,36,16,0.18);
75
75
  }
76
76
 
77
77
  /* ═══════════════════════════════════════════════════════════
@@ -14,6 +14,8 @@ var PAD = 16;
14
14
  var STATUS_COLORS = { created: '#6366f1', assigned: '#f59e0b', in_progress: '#06b6d4', completed: '#22c55e', failed: '#ef4444', cancelled: '#6b7394' };
15
15
  var PRIORITY_COLORS = { urgent: '#ef4444', high: '#f59e0b', normal: '#6366f1', low: '#6b7394' };
16
16
  var DELEGATION_COLORS = { delegation: '#6366f1', review: '#f59e0b', revision: '#f97316', escalation: '#ef4444', return: '#22c55e' };
17
+ var SOURCE_META = { telegram: { icon: '\u2708\uFE0F', label: 'Telegram', color: '#0088cc' }, whatsapp: { icon: '\uD83D\uDCAC', label: 'WhatsApp', color: '#25d366' }, email: { icon: '\u2709\uFE0F', label: 'Email', color: '#ea4335' }, google_chat: { icon: '\uD83D\uDDE8\uFE0F', label: 'Google Chat', color: '#1a73e8' }, internal: { icon: '\u2699\uFE0F', label: 'Internal', color: '#6b7394' }, api: { icon: '\uD83D\uDD17', label: 'API', color: '#8b5cf6' } };
18
+ function sourceBadge(src) { var m = SOURCE_META[src] || { icon: '\uD83D\uDCE8', label: src || 'Unknown', color: '#6b7394' }; return h('span', { style: { display: 'inline-flex', alignItems: 'center', gap: 3, fontSize: 9, padding: '1px 5px', borderRadius: 4, background: m.color + '18', color: m.color, fontWeight: 600, whiteSpace: 'nowrap', flexShrink: 0 } }, m.icon + ' ' + m.label); }
17
19
  // Theme-aware: use CSS variables where possible, detect dark/light
18
20
  function isDark() { try { return window.matchMedia('(prefers-color-scheme: dark)').matches || document.documentElement.classList.contains('dark') || document.body.getAttribute('data-theme') === 'dark'; } catch(e) { return true; } }
19
21
  var BG = 'var(--bg-canvas, var(--bg-primary, #0a0c14))';
@@ -225,6 +227,7 @@ function TaskDetail(props) {
225
227
  h('div', { style: { display: 'flex', gap: 6, marginBottom: 16, alignItems: 'center', flexWrap: 'wrap' } },
226
228
  h('span', { style: { padding: '3px 10px', borderRadius: 12, fontSize: 11, fontWeight: 600, background: statusColor + '22', color: statusColor, border: '1px solid ' + statusColor + '44' } }, task.status.replace('_', ' ').toUpperCase()),
227
229
  h('span', { style: { padding: '3px 10px', borderRadius: 12, fontSize: 11, background: (PRIORITY_COLORS[task.priority] || '#6366f1') + '22', color: PRIORITY_COLORS[task.priority] || '#6366f1' } }, task.priority.toUpperCase()),
230
+ task.source && sourceBadge(task.source),
228
231
  task.chainId && h('span', { style: { padding: '3px 10px', borderRadius: 12, fontSize: 11, background: 'rgba(99,102,241,0.1)', color: '#6366f1', fontFamily: 'var(--font-mono)' } }, 'Chain #' + task.chainId.slice(0, 8)),
229
232
  task.delegationType && tag(DELEGATION_COLORS[task.delegationType] || '#6b7394', task.delegationType)
230
233
  ),
@@ -258,7 +261,8 @@ function TaskDetail(props) {
258
261
  h('div', null, h('div', { style: { color: 'var(--text-muted)', fontSize: 11, marginBottom: 2 } }, 'Created'), h('div', null, task.createdAt ? new Date(task.createdAt).toLocaleString() : '-')),
259
262
  h('div', null, h('div', { style: { color: 'var(--text-muted)', fontSize: 11, marginBottom: 2 } }, 'Duration'), h('div', null, formatDuration(task.actualDurationMs))),
260
263
  h('div', null, h('div', { style: { color: 'var(--text-muted)', fontSize: 11, marginBottom: 2 } }, 'Model'), h('div', null, task.modelUsed || task.model || '-')),
261
- h('div', null, h('div', { style: { color: 'var(--text-muted)', fontSize: 11, marginBottom: 2 } }, 'Tokens / Cost'), h('div', null, (task.tokensUsed || 0).toLocaleString() + ' / $' + (task.costUsd || 0).toFixed(4)))
264
+ h('div', null, h('div', { style: { color: 'var(--text-muted)', fontSize: 11, marginBottom: 2 } }, 'Tokens / Cost'), h('div', null, (task.tokensUsed || 0).toLocaleString() + ' / $' + (task.costUsd || 0).toFixed(4))),
265
+ h('div', null, h('div', { style: { color: 'var(--text-muted)', fontSize: 11, marginBottom: 2 } }, 'Source'), task.source ? sourceBadge(task.source) : h('div', null, '-'))
262
266
  ),
263
267
 
264
268
  // Task chain timeline (if part of a chain)
@@ -737,6 +741,7 @@ export function TaskPipelinePage() {
737
741
  h('div', { style: { display: 'flex', alignItems: 'center', gap: 4, flexWrap: 'nowrap', overflow: 'hidden' } },
738
742
  tag(sc, t.status.replace('_', ' ')),
739
743
  h('span', { style: { fontSize: 9, color: 'var(--tp-text-dim)', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', minWidth: 0 } }, t.assignedToName || t.assignedTo),
744
+ t.source && sourceBadge(t.source),
740
745
  t.delegationType && tag(DELEGATION_COLORS[t.delegationType] || '#6b7394', t.delegationType),
741
746
  h('span', { style: { fontSize: 9, color: 'var(--tp-text-dim)', marginLeft: 'auto' } }, timeAgo(t.createdAt))
742
747
  ),
@@ -840,14 +845,14 @@ export function TaskPipelinePage() {
840
845
  return h('div', {
841
846
  key: i,
842
847
  className: 'tp-node',
843
- onClick: function(e) { e.stopPropagation(); if (step.taskId) { var ct = expandedChain.find(function(c) { return c.id === step.taskId; }); if (ct) openTaskDetail(ct); } },
848
+ onClick: function(e) { e.stopPropagation(); if (step.taskId) { var ct = expandedChain.find(function(c) { return c.id === step.taskId; }); if (ct) openTaskDetail(ct); } else if (expandedChain.length > 0) { openTaskDetail(expandedChain[0]); } },
844
849
  style: {
845
850
  position: 'absolute', left: x, top: 4, width: isTerminal ? 'auto' : STEP_W, minWidth: isTerminal ? 90 : undefined, height: STEP_H,
846
851
  background: isTerminal ? sc + '15' : isMe ? 'rgba(255,255,255,0.06)' : 'rgba(255,255,255,0.02)',
847
852
  border: '1px solid ' + (isTerminal ? sc + '44' : isMe ? sc : 'rgba(255,255,255,0.1)'),
848
853
  borderRadius: isTerminal ? 18 : 6,
849
854
  display: 'flex', alignItems: 'center', gap: 6, padding: '0 8px',
850
- cursor: step.taskId ? 'pointer' : 'default',
855
+ cursor: 'pointer',
851
856
  },
852
857
  },
853
858
  // Avatar
package/dist/index.js CHANGED
@@ -7,7 +7,7 @@ import {
7
7
  import {
8
8
  provision,
9
9
  runSetupWizard
10
- } from "./chunk-UHB3PVLC.js";
10
+ } from "./chunk-2HW54CJF.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-TBG5SA5C.js";
31
+ } from "./chunk-OFDHFNAL.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-PAPADBZ7.js";
45
+ } from "./chunk-QUY235JZ.js";
46
46
  import "./chunk-OF4MUWWS.js";
47
47
  import {
48
48
  PROVIDER_REGISTRY,