@agenticmail/enterprise 0.5.5 → 0.5.7

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.
Files changed (40) hide show
  1. package/dist/chunk-2AHKTK2N.js +819 -0
  2. package/dist/chunk-2ESYSVXG.js +48 -0
  3. package/dist/chunk-BRKFYP4K.js +878 -0
  4. package/dist/chunk-FVXEXRP2.js +12666 -0
  5. package/dist/chunk-OZZ65RAG.js +9040 -0
  6. package/dist/chunk-P2FILRUE.js +591 -0
  7. package/dist/chunk-Q3ZHFVGV.js +48 -0
  8. package/dist/chunk-TCIGK4HQ.js +1943 -0
  9. package/dist/chunk-WI62KTVK.js +3455 -0
  10. package/dist/cidr-O6T7HDUD.js +17 -0
  11. package/dist/cli-build-skill-MP6K4ZXO.js +235 -0
  12. package/dist/cli-recover-5VWKSBTE.js +97 -0
  13. package/dist/cli-submit-skill-6AAQWZWW.js +162 -0
  14. package/dist/cli-validate-DHESCL7V.js +148 -0
  15. package/dist/cli-verify-G27G44PM.js +98 -0
  16. package/dist/cli.js +6 -6
  17. package/dist/config-store-YW6BMVSU.js +58 -0
  18. package/dist/db-adapter-WPKXQDEY.js +7 -0
  19. package/dist/domain-lock-XXXJIX7D.js +7 -0
  20. package/dist/dynamodb-33B2BXRN.js +426 -0
  21. package/dist/esm-BZF7GNJD.js +5090 -0
  22. package/dist/factory-X6SKUEDX.js +9 -0
  23. package/dist/firewall-ZGR2AGAP.js +10 -0
  24. package/dist/index.js +35 -35
  25. package/dist/managed-J3QQMQQJ.js +16 -0
  26. package/dist/mongodb-KTICSLUI.js +319 -0
  27. package/dist/mysql-VIFJFM4A.js +574 -0
  28. package/dist/postgres-A67RQTZX.js +575 -0
  29. package/dist/registry/cli.js +1 -1
  30. package/dist/routes-F22OJNEY.js +5674 -0
  31. package/dist/runtime-TCAE7QSD.js +47 -0
  32. package/dist/server-B27VUUU6.js +11 -0
  33. package/dist/setup-UIQKEGIG.js +20 -0
  34. package/dist/setup-UIYXH2L3.js +20 -0
  35. package/dist/skills-NJKTYIGZ.js +14 -0
  36. package/dist/sqlite-Y6GS6AE3.js +490 -0
  37. package/dist/turso-A7AO3JDH.js +495 -0
  38. package/package.json +1 -1
  39. package/src/setup/index.ts +19 -3
  40. package/src/setup/registration.ts +86 -12
@@ -0,0 +1,9 @@
1
+ import {
2
+ createAdapter,
3
+ getSupportedDatabases
4
+ } from "./chunk-Q3ZHFVGV.js";
5
+ import "./chunk-2ESYSVXG.js";
6
+ export {
7
+ createAdapter,
8
+ getSupportedDatabases
9
+ };
@@ -0,0 +1,10 @@
1
+ import {
2
+ invalidateFirewallCache,
3
+ ipAccessControl
4
+ } from "./chunk-RO537U6H.js";
5
+ import "./chunk-DRXMYYKN.js";
6
+ import "./chunk-2ESYSVXG.js";
7
+ export {
8
+ invalidateFirewallCache,
9
+ ipAccessControl
10
+ };
package/dist/index.js CHANGED
@@ -1,3 +1,18 @@
1
+ import {
2
+ AgentRuntime,
3
+ EmailChannel,
4
+ FollowUpScheduler,
5
+ SessionManager,
6
+ SubAgentManager,
7
+ ToolRegistry,
8
+ callLLM,
9
+ createAgentRuntime,
10
+ createNoopHooks,
11
+ createRuntimeHooks,
12
+ executeTool,
13
+ runAgentLoop,
14
+ toolsToDefinitions
15
+ } from "./chunk-FVXEXRP2.js";
1
16
  import {
2
17
  ValidationError,
3
18
  auditLogger,
@@ -11,11 +26,17 @@ import {
11
26
  requireRole,
12
27
  securityHeaders,
13
28
  validate
14
- } from "./chunk-ISOODMEF.js";
29
+ } from "./chunk-TCIGK4HQ.js";
30
+ import {
31
+ PROVIDER_REGISTRY,
32
+ listAllProviders,
33
+ resolveApiKeyForProvider,
34
+ resolveProvider
35
+ } from "./chunk-ZNR5DDTA.js";
15
36
  import {
16
37
  provision,
17
38
  runSetupWizard
18
- } from "./chunk-6CVIA5YL.js";
39
+ } from "./chunk-BRKFYP4K.js";
19
40
  import {
20
41
  ENGINE_TABLES,
21
42
  ENGINE_TABLES_POSTGRES,
@@ -56,33 +77,7 @@ import {
56
77
  TenantManager,
57
78
  WorkforceManager,
58
79
  init_guardrails
59
- } from "./chunk-EVQPFQ55.js";
60
- import {
61
- BUILTIN_SKILLS,
62
- PRESET_PROFILES,
63
- PermissionEngine
64
- } from "./chunk-LKAFZ343.js";
65
- import {
66
- AgentRuntime,
67
- EmailChannel,
68
- FollowUpScheduler,
69
- SessionManager,
70
- SubAgentManager,
71
- ToolRegistry,
72
- callLLM,
73
- createAgentRuntime,
74
- createNoopHooks,
75
- createRuntimeHooks,
76
- executeTool,
77
- runAgentLoop,
78
- toolsToDefinitions
79
- } from "./chunk-JMTNHH7I.js";
80
- import {
81
- PROVIDER_REGISTRY,
82
- listAllProviders,
83
- resolveApiKeyForProvider,
84
- resolveProvider
85
- } from "./chunk-ZNR5DDTA.js";
80
+ } from "./chunk-OZZ65RAG.js";
86
81
  import "./chunk-TYW5XTOW.js";
87
82
  import {
88
83
  CircuitBreaker,
@@ -92,10 +87,18 @@ import {
92
87
  RateLimiter,
93
88
  withRetry
94
89
  } from "./chunk-JLSQOQ5L.js";
90
+ import {
91
+ BUILTIN_SKILLS,
92
+ PRESET_PROFILES,
93
+ PermissionEngine
94
+ } from "./chunk-P2FILRUE.js";
95
+ import {
96
+ DatabaseAdapter
97
+ } from "./chunk-FLRYMSKY.js";
95
98
  import {
96
99
  createAdapter,
97
100
  getSupportedDatabases
98
- } from "./chunk-NTVN3JHS.js";
101
+ } from "./chunk-Q3ZHFVGV.js";
99
102
  import {
100
103
  AGENTICMAIL_TOOLS,
101
104
  ALL_TOOLS,
@@ -104,7 +107,7 @@ import {
104
107
  generateToolPolicy,
105
108
  getToolsBySkill,
106
109
  init_tool_catalog
107
- } from "./chunk-X6UVWFHW.js";
110
+ } from "./chunk-WI62KTVK.js";
108
111
  import {
109
112
  VALID_CATEGORIES,
110
113
  VALID_RISK_LEVELS,
@@ -114,10 +117,7 @@ import {
114
117
  collectCommunityToolIds,
115
118
  validateSkillManifest
116
119
  } from "./chunk-TY7NVD4U.js";
117
- import {
118
- DatabaseAdapter
119
- } from "./chunk-FLRYMSKY.js";
120
- import "./chunk-KFQGP6VL.js";
120
+ import "./chunk-2ESYSVXG.js";
121
121
 
122
122
  // src/engine/index.ts
123
123
  init_tool_catalog();
@@ -0,0 +1,16 @@
1
+ import {
2
+ deployToCloud,
3
+ generateDockerCompose,
4
+ generateEnvFile,
5
+ generateFlyToml,
6
+ generateRailwayConfig
7
+ } from "./chunk-7FVRYOP4.js";
8
+ import "./chunk-JLSQOQ5L.js";
9
+ import "./chunk-2ESYSVXG.js";
10
+ export {
11
+ deployToCloud,
12
+ generateDockerCompose,
13
+ generateEnvFile,
14
+ generateFlyToml,
15
+ generateRailwayConfig
16
+ };
@@ -0,0 +1,319 @@
1
+ import {
2
+ DatabaseAdapter
3
+ } from "./chunk-FLRYMSKY.js";
4
+ import "./chunk-2ESYSVXG.js";
5
+
6
+ // src/db/mongodb.ts
7
+ import { randomUUID, createHash } from "crypto";
8
+ var mongoMod;
9
+ async function getMongo() {
10
+ if (!mongoMod) {
11
+ try {
12
+ mongoMod = await import("mongodb");
13
+ } catch {
14
+ throw new Error("MongoDB driver not found. Install: npm install mongodb");
15
+ }
16
+ }
17
+ return mongoMod;
18
+ }
19
+ var MongoAdapter = class extends DatabaseAdapter {
20
+ type = "mongodb";
21
+ client = null;
22
+ db = null;
23
+ async connect(config) {
24
+ const { MongoClient } = await getMongo();
25
+ const uri = config.connectionString || `mongodb://${config.host || "localhost"}:${config.port || 27017}`;
26
+ this.client = new MongoClient(uri);
27
+ await this.client.connect();
28
+ const dbName = config.database || new URL(uri.replace("mongodb+srv://", "https://")).pathname.slice(1) || "agenticmail";
29
+ this.db = this.client.db(dbName);
30
+ }
31
+ async disconnect() {
32
+ if (this.client) await this.client.close();
33
+ }
34
+ isConnected() {
35
+ return this.client !== null;
36
+ }
37
+ col(name) {
38
+ return this.db.collection(name);
39
+ }
40
+ async migrate() {
41
+ await this.col("agents").createIndex({ name: 1 }, { unique: true });
42
+ await this.col("agents").createIndex({ email: 1 }, { unique: true });
43
+ await this.col("agents").createIndex({ status: 1 });
44
+ await this.col("users").createIndex({ email: 1 }, { unique: true });
45
+ await this.col("users").createIndex({ ssoProvider: 1, ssoSubject: 1 });
46
+ await this.col("audit_log").createIndex({ timestamp: -1 });
47
+ await this.col("audit_log").createIndex({ actor: 1 });
48
+ await this.col("audit_log").createIndex({ action: 1 });
49
+ await this.col("api_keys").createIndex({ keyHash: 1 }, { unique: true });
50
+ await this.col("email_rules").createIndex({ agentId: 1 });
51
+ await this.col("settings").updateOne(
52
+ { _id: "default" },
53
+ { $setOnInsert: { name: "", subdomain: "", plan: "free", primaryColor: "#6366f1", createdAt: /* @__PURE__ */ new Date(), updatedAt: /* @__PURE__ */ new Date() } },
54
+ { upsert: true }
55
+ );
56
+ await this.col("retention_policy").updateOne(
57
+ { _id: "default" },
58
+ { $setOnInsert: { enabled: false, retainDays: 365, excludeTags: [], archiveFirst: true } },
59
+ { upsert: true }
60
+ );
61
+ }
62
+ // ─── Company ─────────────────────────────────────────────
63
+ async getSettings() {
64
+ const r = await this.col("settings").findOne({ _id: "default" });
65
+ if (!r) return null;
66
+ return { id: "default", name: r.name, domain: r.domain, subdomain: r.subdomain, smtpHost: r.smtpHost, smtpPort: r.smtpPort, smtpUser: r.smtpUser, smtpPass: r.smtpPass, dkimPrivateKey: r.dkimPrivateKey, logoUrl: r.logoUrl, primaryColor: r.primaryColor, ssoConfig: r.ssoConfig, toolSecurityConfig: r.toolSecurityConfig || {}, firewallConfig: r.firewallConfig || {}, modelPricingConfig: r.modelPricingConfig || {}, plan: r.plan, deploymentKeyHash: r.deploymentKeyHash, domainRegistrationId: r.domainRegistrationId, domainDnsChallenge: r.domainDnsChallenge, domainVerifiedAt: r.domainVerifiedAt || void 0, domainRegisteredAt: r.domainRegisteredAt || void 0, domainStatus: r.domainStatus || "unregistered", createdAt: r.createdAt, updatedAt: r.updatedAt };
67
+ }
68
+ async updateSettings(updates) {
69
+ const { id, ...rest } = updates;
70
+ await this.col("settings").updateOne({ _id: "default" }, { $set: { ...rest, updatedAt: /* @__PURE__ */ new Date() } }, { upsert: true });
71
+ return this.getSettings();
72
+ }
73
+ // ─── Agents ──────────────────────────────────────────────
74
+ async createAgent(input) {
75
+ const doc = {
76
+ _id: input.id || randomUUID(),
77
+ name: input.name,
78
+ email: input.email || `${input.name.toLowerCase().replace(/\s+/g, "-")}@localhost`,
79
+ role: input.role || "assistant",
80
+ status: "active",
81
+ metadata: input.metadata || {},
82
+ createdBy: input.createdBy,
83
+ createdAt: /* @__PURE__ */ new Date(),
84
+ updatedAt: /* @__PURE__ */ new Date()
85
+ };
86
+ await this.col("agents").insertOne(doc);
87
+ return this.docToAgent(doc);
88
+ }
89
+ async getAgent(id) {
90
+ const r = await this.col("agents").findOne({ _id: id });
91
+ return r ? this.docToAgent(r) : null;
92
+ }
93
+ async getAgentByName(name) {
94
+ const r = await this.col("agents").findOne({ name });
95
+ return r ? this.docToAgent(r) : null;
96
+ }
97
+ async listAgents(opts) {
98
+ const filter = {};
99
+ if (opts?.status) filter.status = opts.status;
100
+ const cursor = this.col("agents").find(filter).sort({ createdAt: -1 });
101
+ if (opts?.offset) cursor.skip(opts.offset);
102
+ if (opts?.limit) cursor.limit(opts.limit);
103
+ return (await cursor.toArray()).map((r) => this.docToAgent(r));
104
+ }
105
+ async updateAgent(id, updates) {
106
+ const set = { updatedAt: /* @__PURE__ */ new Date() };
107
+ for (const key of ["name", "email", "role", "status", "metadata"]) {
108
+ if (updates[key] !== void 0) set[key] = updates[key];
109
+ }
110
+ await this.col("agents").updateOne({ _id: id }, { $set: set });
111
+ return await this.getAgent(id);
112
+ }
113
+ async archiveAgent(id) {
114
+ await this.col("agents").updateOne({ _id: id }, { $set: { status: "archived", updatedAt: /* @__PURE__ */ new Date() } });
115
+ }
116
+ async deleteAgent(id) {
117
+ await this.col("agents").deleteOne({ _id: id });
118
+ }
119
+ async countAgents(status) {
120
+ const filter = {};
121
+ if (status) filter.status = status;
122
+ return this.col("agents").countDocuments(filter);
123
+ }
124
+ // ─── Users ───────────────────────────────────────────────
125
+ async createUser(input) {
126
+ let passwordHash = null;
127
+ if (input.password) {
128
+ const { default: bcrypt } = await import("bcryptjs");
129
+ passwordHash = await bcrypt.hash(input.password, 12);
130
+ }
131
+ const doc = {
132
+ _id: randomUUID(),
133
+ email: input.email,
134
+ name: input.name,
135
+ role: input.role,
136
+ passwordHash,
137
+ ssoProvider: input.ssoProvider || null,
138
+ ssoSubject: input.ssoSubject || null,
139
+ createdAt: /* @__PURE__ */ new Date(),
140
+ updatedAt: /* @__PURE__ */ new Date(),
141
+ lastLoginAt: null
142
+ };
143
+ await this.col("users").insertOne(doc);
144
+ return this.docToUser(doc);
145
+ }
146
+ async getUser(id) {
147
+ const r = await this.col("users").findOne({ _id: id });
148
+ return r ? this.docToUser(r) : null;
149
+ }
150
+ async getUserByEmail(email) {
151
+ const r = await this.col("users").findOne({ email });
152
+ return r ? this.docToUser(r) : null;
153
+ }
154
+ async getUserBySso(provider, subject) {
155
+ const r = await this.col("users").findOne({ ssoProvider: provider, ssoSubject: subject });
156
+ return r ? this.docToUser(r) : null;
157
+ }
158
+ async listUsers(opts) {
159
+ const cursor = this.col("users").find({}).sort({ createdAt: -1 });
160
+ if (opts?.offset) cursor.skip(opts.offset);
161
+ if (opts?.limit) cursor.limit(opts.limit);
162
+ return (await cursor.toArray()).map((r) => this.docToUser(r));
163
+ }
164
+ async updateUser(id, updates) {
165
+ const set = { updatedAt: /* @__PURE__ */ new Date() };
166
+ for (const key of ["email", "name", "role", "lastLoginAt"]) {
167
+ if (updates[key] !== void 0) set[key] = updates[key];
168
+ }
169
+ await this.col("users").updateOne({ _id: id }, { $set: set });
170
+ return await this.getUser(id);
171
+ }
172
+ async deleteUser(id) {
173
+ await this.col("users").deleteOne({ _id: id });
174
+ }
175
+ // ─── Audit ───────────────────────────────────────────────
176
+ async logEvent(event) {
177
+ await this.col("audit_log").insertOne({
178
+ _id: randomUUID(),
179
+ timestamp: /* @__PURE__ */ new Date(),
180
+ actor: event.actor,
181
+ actorType: event.actorType,
182
+ action: event.action,
183
+ resource: event.resource,
184
+ details: event.details || {},
185
+ ip: event.ip || null
186
+ });
187
+ }
188
+ async queryAudit(filters) {
189
+ const filter = {};
190
+ if (filters.actor) filter.actor = filters.actor;
191
+ if (filters.action) filter.action = filters.action;
192
+ if (filters.resource) filter.resource = { $regex: filters.resource, $options: "i" };
193
+ if (filters.from || filters.to) {
194
+ filter.timestamp = {};
195
+ if (filters.from) filter.timestamp.$gte = filters.from;
196
+ if (filters.to) filter.timestamp.$lte = filters.to;
197
+ }
198
+ const total = await this.col("audit_log").countDocuments(filter);
199
+ const cursor = this.col("audit_log").find(filter).sort({ timestamp: -1 });
200
+ if (filters.offset) cursor.skip(filters.offset);
201
+ if (filters.limit) cursor.limit(filters.limit);
202
+ const rows = await cursor.toArray();
203
+ return {
204
+ events: rows.map((r) => ({
205
+ id: r._id,
206
+ timestamp: r.timestamp,
207
+ actor: r.actor,
208
+ actorType: r.actorType,
209
+ action: r.action,
210
+ resource: r.resource,
211
+ details: r.details,
212
+ ip: r.ip
213
+ })),
214
+ total
215
+ };
216
+ }
217
+ // ─── API Keys ────────────────────────────────────────────
218
+ async createApiKey(input) {
219
+ const id = randomUUID();
220
+ const plaintext = `ek_${randomUUID().replace(/-/g, "")}`;
221
+ const keyHash = createHash("sha256").update(plaintext).digest("hex");
222
+ const keyPrefix = plaintext.substring(0, 11);
223
+ const doc = {
224
+ _id: id,
225
+ name: input.name,
226
+ keyHash,
227
+ keyPrefix,
228
+ scopes: input.scopes,
229
+ createdBy: input.createdBy,
230
+ createdAt: /* @__PURE__ */ new Date(),
231
+ lastUsedAt: null,
232
+ expiresAt: input.expiresAt || null,
233
+ revoked: false
234
+ };
235
+ await this.col("api_keys").insertOne(doc);
236
+ return { key: this.docToApiKey(doc), plaintext };
237
+ }
238
+ async getApiKey(id) {
239
+ const r = await this.col("api_keys").findOne({ _id: id });
240
+ return r ? this.docToApiKey(r) : null;
241
+ }
242
+ async validateApiKey(plaintext) {
243
+ const keyHash = createHash("sha256").update(plaintext).digest("hex");
244
+ const r = await this.col("api_keys").findOne({ keyHash, revoked: false });
245
+ if (!r) return null;
246
+ const key = this.docToApiKey(r);
247
+ if (key.expiresAt && /* @__PURE__ */ new Date() > key.expiresAt) return null;
248
+ await this.col("api_keys").updateOne({ _id: r._id }, { $set: { lastUsedAt: /* @__PURE__ */ new Date() } });
249
+ return key;
250
+ }
251
+ async listApiKeys(opts) {
252
+ const filter = {};
253
+ if (opts?.createdBy) filter.createdBy = opts.createdBy;
254
+ return (await this.col("api_keys").find(filter).sort({ createdAt: -1 }).toArray()).map((r) => this.docToApiKey(r));
255
+ }
256
+ async revokeApiKey(id) {
257
+ await this.col("api_keys").updateOne({ _id: id }, { $set: { revoked: true } });
258
+ }
259
+ // ─── Rules ───────────────────────────────────────────────
260
+ async createRule(rule) {
261
+ const doc = {
262
+ _id: randomUUID(),
263
+ ...rule,
264
+ createdAt: /* @__PURE__ */ new Date(),
265
+ updatedAt: /* @__PURE__ */ new Date()
266
+ };
267
+ await this.col("email_rules").insertOne(doc);
268
+ return this.docToRule(doc);
269
+ }
270
+ async getRules(agentId) {
271
+ const filter = {};
272
+ if (agentId) filter.$or = [{ agentId }, { agentId: null }];
273
+ return (await this.col("email_rules").find(filter).sort({ priority: -1 }).toArray()).map((r) => this.docToRule(r));
274
+ }
275
+ async updateRule(id, updates) {
276
+ const { id: _id, createdAt, ...rest } = updates;
277
+ await this.col("email_rules").updateOne({ _id: id }, { $set: { ...rest, updatedAt: /* @__PURE__ */ new Date() } });
278
+ const r = await this.col("email_rules").findOne({ _id: id });
279
+ return this.docToRule(r);
280
+ }
281
+ async deleteRule(id) {
282
+ await this.col("email_rules").deleteOne({ _id: id });
283
+ }
284
+ // ─── Retention ───────────────────────────────────────────
285
+ async getRetentionPolicy() {
286
+ const r = await this.col("retention_policy").findOne({ _id: "default" });
287
+ if (!r) return { enabled: false, retainDays: 365, archiveFirst: true };
288
+ return { enabled: r.enabled, retainDays: r.retainDays, excludeTags: r.excludeTags || [], archiveFirst: r.archiveFirst };
289
+ }
290
+ async setRetentionPolicy(policy) {
291
+ await this.col("retention_policy").updateOne({ _id: "default" }, { $set: policy }, { upsert: true });
292
+ }
293
+ // ─── Stats ───────────────────────────────────────────────
294
+ async getStats() {
295
+ const [totalAgents, activeAgents, totalUsers, totalAuditEvents] = await Promise.all([
296
+ this.col("agents").countDocuments(),
297
+ this.col("agents").countDocuments({ status: "active" }),
298
+ this.col("users").countDocuments(),
299
+ this.col("audit_log").countDocuments()
300
+ ]);
301
+ return { totalAgents, activeAgents, totalUsers, totalEmails: 0, totalAuditEvents };
302
+ }
303
+ // ─── Mappers ─────────────────────────────────────────────
304
+ docToAgent(r) {
305
+ return { id: r._id, name: r.name, email: r.email, role: r.role, status: r.status, metadata: r.metadata || {}, createdBy: r.createdBy, createdAt: r.createdAt, updatedAt: r.updatedAt };
306
+ }
307
+ docToUser(r) {
308
+ return { id: r._id, email: r.email, name: r.name, role: r.role, passwordHash: r.passwordHash, ssoProvider: r.ssoProvider, ssoSubject: r.ssoSubject, createdAt: r.createdAt, updatedAt: r.updatedAt, lastLoginAt: r.lastLoginAt || void 0 };
309
+ }
310
+ docToApiKey(r) {
311
+ return { id: r._id, name: r.name, keyHash: r.keyHash, keyPrefix: r.keyPrefix, scopes: r.scopes || [], createdBy: r.createdBy, createdAt: r.createdAt, lastUsedAt: r.lastUsedAt || void 0, expiresAt: r.expiresAt || void 0, revoked: r.revoked };
312
+ }
313
+ docToRule(r) {
314
+ return { id: r._id, name: r.name, agentId: r.agentId, conditions: r.conditions || {}, actions: r.actions || {}, priority: r.priority, enabled: r.enabled, createdAt: r.createdAt, updatedAt: r.updatedAt };
315
+ }
316
+ };
317
+ export {
318
+ MongoAdapter
319
+ };