@agenticmail/enterprise 0.5.57 → 0.5.58

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,47 @@
1
+ import {
2
+ AgentRuntime,
3
+ EmailChannel,
4
+ FollowUpScheduler,
5
+ SessionManager,
6
+ SubAgentManager,
7
+ ToolRegistry,
8
+ callLLM,
9
+ createAgentRuntime,
10
+ createNoopHooks,
11
+ createRuntimeHooks,
12
+ estimateMessageTokens,
13
+ estimateTokens,
14
+ executeTool,
15
+ runAgentLoop,
16
+ toolsToDefinitions
17
+ } from "./chunk-RDNVJJ6R.js";
18
+ import "./chunk-TYW5XTOW.js";
19
+ import "./chunk-JLSQOQ5L.js";
20
+ import {
21
+ PROVIDER_REGISTRY,
22
+ listAllProviders,
23
+ resolveApiKeyForProvider,
24
+ resolveProvider
25
+ } from "./chunk-67KZYSLU.js";
26
+ import "./chunk-KFQGP6VL.js";
27
+ export {
28
+ AgentRuntime,
29
+ EmailChannel,
30
+ FollowUpScheduler,
31
+ PROVIDER_REGISTRY,
32
+ SessionManager,
33
+ SubAgentManager,
34
+ ToolRegistry,
35
+ callLLM,
36
+ createAgentRuntime,
37
+ createNoopHooks,
38
+ createRuntimeHooks,
39
+ estimateMessageTokens,
40
+ estimateTokens,
41
+ executeTool,
42
+ listAllProviders,
43
+ resolveApiKeyForProvider,
44
+ resolveProvider,
45
+ runAgentLoop,
46
+ toolsToDefinitions
47
+ };
@@ -0,0 +1,12 @@
1
+ import {
2
+ createServer
3
+ } from "./chunk-WIRNO7VS.js";
4
+ import "./chunk-3SMTCIR4.js";
5
+ import "./chunk-JLSQOQ5L.js";
6
+ import "./chunk-RO537U6H.js";
7
+ import "./chunk-DRXMYYKN.js";
8
+ import "./chunk-67KZYSLU.js";
9
+ import "./chunk-KFQGP6VL.js";
10
+ export {
11
+ createServer
12
+ };
@@ -0,0 +1,20 @@
1
+ import {
2
+ promptCompanyInfo,
3
+ promptDatabase,
4
+ promptDeployment,
5
+ promptDomain,
6
+ promptRegistration,
7
+ provision,
8
+ runSetupWizard
9
+ } from "./chunk-K2WM5ZXQ.js";
10
+ import "./chunk-M4PRT53C.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.57",
3
+ "version": "0.5.58",
4
4
  "description": "AgenticMail Enterprise — cloud-hosted AI agent identity, email, auth & compliance for organizations",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1241,6 +1241,62 @@ CREATE INDEX idx_agent_followups_agent ON agent_followups(agent_id);
1241
1241
  mysql: `SELECT 1;`,
1242
1242
  nosql: async () => {},
1243
1243
  },
1244
+ {
1245
+ version: 18,
1246
+ name: 'knowledge_contribution_bases',
1247
+ sql: `
1248
+ CREATE TABLE IF NOT EXISTS knowledge_contribution_bases (
1249
+ id TEXT PRIMARY KEY,
1250
+ org_id TEXT NOT NULL,
1251
+ name TEXT NOT NULL,
1252
+ description TEXT,
1253
+ role TEXT NOT NULL DEFAULT 'general',
1254
+ data JSON NOT NULL DEFAULT '{}',
1255
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
1256
+ updated_at TEXT NOT NULL DEFAULT (datetime('now'))
1257
+ );
1258
+ CREATE INDEX IF NOT EXISTS idx_kc_bases_org ON knowledge_contribution_bases(org_id);
1259
+
1260
+ CREATE TABLE IF NOT EXISTS knowledge_contribution_entries (
1261
+ id TEXT PRIMARY KEY,
1262
+ base_id TEXT NOT NULL,
1263
+ org_id TEXT NOT NULL,
1264
+ source_agent_id TEXT NOT NULL,
1265
+ category TEXT,
1266
+ data JSON NOT NULL DEFAULT '{}',
1267
+ created_at TEXT NOT NULL DEFAULT (datetime('now')),
1268
+ FOREIGN KEY (base_id) REFERENCES knowledge_contribution_bases(id) ON DELETE CASCADE
1269
+ );
1270
+ CREATE INDEX IF NOT EXISTS idx_kc_entries_base ON knowledge_contribution_entries(base_id);
1271
+ `,
1272
+ postgres: `
1273
+ CREATE TABLE IF NOT EXISTS knowledge_contribution_bases (
1274
+ id TEXT PRIMARY KEY,
1275
+ org_id TEXT NOT NULL,
1276
+ name TEXT NOT NULL,
1277
+ description TEXT,
1278
+ role TEXT NOT NULL DEFAULT 'general',
1279
+ data JSONB NOT NULL DEFAULT '{}',
1280
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
1281
+ updated_at TIMESTAMPTZ NOT NULL DEFAULT NOW()
1282
+ );
1283
+ CREATE INDEX IF NOT EXISTS idx_kc_bases_org ON knowledge_contribution_bases(org_id);
1284
+
1285
+ CREATE TABLE IF NOT EXISTS knowledge_contribution_entries (
1286
+ id TEXT PRIMARY KEY,
1287
+ base_id TEXT NOT NULL,
1288
+ org_id TEXT NOT NULL,
1289
+ source_agent_id TEXT NOT NULL,
1290
+ category TEXT,
1291
+ data JSONB NOT NULL DEFAULT '{}',
1292
+ created_at TIMESTAMPTZ NOT NULL DEFAULT NOW(),
1293
+ FOREIGN KEY (base_id) REFERENCES knowledge_contribution_bases(id) ON DELETE CASCADE
1294
+ );
1295
+ CREATE INDEX IF NOT EXISTS idx_kc_entries_base ON knowledge_contribution_entries(base_id);
1296
+ `,
1297
+ mysql: `SELECT 1;`,
1298
+ nosql: async () => {},
1299
+ },
1244
1300
  ];
1245
1301
 
1246
1302
  // ─── Dynamic Table Definitions ─────────────────────────
@@ -339,10 +339,70 @@ export class KnowledgeContributionManager {
339
339
  /** Contributor tracking: baseId -> Set of agent IDs that contributed */
340
340
  private baseContributors = new Map<string, Set<string>>();
341
341
 
342
+ private db?: any; // DatabaseAdapter
343
+
342
344
  constructor(opts?: { memoryCallback?: MemoryCallback }) {
343
345
  this.memoryCallback = opts?.memoryCallback;
344
346
  }
345
347
 
348
+ async setDb(db: any): Promise<void> {
349
+ this.db = db;
350
+ // Load persisted bases
351
+ try {
352
+ const rows = await db.all('SELECT * FROM knowledge_contribution_bases ORDER BY created_at');
353
+ for (const row of rows || []) {
354
+ const data = typeof row.data === 'string' ? JSON.parse(row.data) : (row.data || {});
355
+ const base: KnowledgeBase = {
356
+ id: row.id,
357
+ orgId: row.org_id,
358
+ name: row.name,
359
+ description: row.description,
360
+ role: row.role as KnowledgeRole,
361
+ categories: data.categories || [],
362
+ contributorCount: data.contributorCount || 0,
363
+ entryCount: data.entryCount || 0,
364
+ lastContributionAt: data.lastContributionAt || row.updated_at,
365
+ createdAt: row.created_at,
366
+ updatedAt: row.updated_at,
367
+ };
368
+ this.bases.set(base.id, base);
369
+ }
370
+ // Load entries
371
+ const entryRows = await db.all('SELECT * FROM knowledge_contribution_entries ORDER BY created_at');
372
+ for (const row of entryRows || []) {
373
+ const data = typeof row.data === 'string' ? JSON.parse(row.data) : (row.data || {});
374
+ const entry: KnowledgeEntry = { id: row.id, baseId: row.base_id, sourceAgentId: row.source_agent_id, category: row.category, ...data, createdAt: row.created_at };
375
+ this.entries.set(entry.id, entry);
376
+ this.indexEntryAdd(entry);
377
+ }
378
+ } catch (e) {
379
+ // Table may not exist yet (pre-migration)
380
+ }
381
+ }
382
+
383
+ private async persistBase(base: KnowledgeBase): Promise<void> {
384
+ if (!this.db) return;
385
+ const data = JSON.stringify({ categories: base.categories, contributorCount: base.contributorCount, entryCount: base.entryCount, lastContributionAt: base.lastContributionAt });
386
+ await this.db.run(
387
+ `INSERT INTO knowledge_contribution_bases (id, org_id, name, description, role, data, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET name=excluded.name, description=excluded.description, data=excluded.data, updated_at=excluded.updated_at`,
388
+ [base.id, base.orgId, base.name, base.description || '', base.role, data, base.createdAt, base.updatedAt]
389
+ );
390
+ }
391
+
392
+ private async persistEntry(entry: KnowledgeEntry): Promise<void> {
393
+ if (!this.db) return;
394
+ const { id, baseId, sourceAgentId, category, createdAt, ...rest } = entry;
395
+ await this.db.run(
396
+ `INSERT INTO knowledge_contribution_entries (id, base_id, org_id, source_agent_id, category, data, created_at) VALUES (?, ?, ?, ?, ?, ?, ?) ON CONFLICT(id) DO UPDATE SET data=excluded.data`,
397
+ [id, baseId, this.bases.get(baseId)?.orgId || '', sourceAgentId, category || '', JSON.stringify(rest), createdAt]
398
+ );
399
+ }
400
+
401
+ private async deleteBaseFromDb(baseId: string): Promise<void> {
402
+ if (!this.db) return;
403
+ await this.db.run('DELETE FROM knowledge_contribution_bases WHERE id = ?', [baseId]);
404
+ }
405
+
346
406
  // ─── Index Helpers ──────────────────────────────────
347
407
 
348
408
  private indexEntryAdd(entry: KnowledgeEntry): void {
@@ -443,6 +503,7 @@ export class KnowledgeContributionManager {
443
503
  };
444
504
 
445
505
  this.bases.set(base.id, base);
506
+ this.persistBase(base).catch(() => {});
446
507
  return base;
447
508
  }
448
509
 
@@ -498,6 +559,7 @@ export class KnowledgeContributionManager {
498
559
  }
499
560
 
500
561
  this.bases.delete(baseId);
562
+ this.deleteBaseFromDb(baseId).catch(() => {});
501
563
  }
502
564
 
503
565
  // ─── Roles ──────────────────────────────────────────
@@ -613,6 +675,8 @@ export class KnowledgeContributionManager {
613
675
  category.entryCount = this.getEntriesForBase(opts.baseId)
614
676
  .filter(e => e.categoryId === opts.categoryId).length;
615
677
 
678
+ this.persistEntry(entry).catch(() => {});
679
+ this.persistBase(base).catch(() => {});
616
680
  return entry;
617
681
  }
618
682
 
@@ -242,6 +242,7 @@ export async function setEngineDb(
242
242
  journal.setDb(db),
243
243
  compliance.setDb(db),
244
244
  communityRegistry.setDb(db),
245
+ knowledgeContribution.setDb(db),
245
246
  workforce.setDb(db),
246
247
  policyEngine.setDb(db),
247
248
  memoryManager.setDb(db),