@agenticmail/enterprise 0.5.36 → 0.5.38

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-25QRPLMP.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,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-EV2KJZS3.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-PRO5D4X3.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,12 @@
1
+ import {
2
+ createServer
3
+ } from "./chunk-4ZUFG4UA.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-KKS2HTV4.js";
10
+ import "./chunk-WEWW2XJW.js";
11
+ import "./chunk-KFQGP6VL.js";
12
+ export {
13
+ promptCompanyInfo,
14
+ promptDatabase,
15
+ promptDeployment,
16
+ promptDomain,
17
+ promptRegistration,
18
+ provision,
19
+ runSetupWizard
20
+ };
@@ -0,0 +1,20 @@
1
+ import {
2
+ promptCompanyInfo,
3
+ promptDatabase,
4
+ promptDeployment,
5
+ promptDomain,
6
+ promptRegistration,
7
+ provision,
8
+ runSetupWizard
9
+ } from "./chunk-T3CNJPFP.js";
10
+ import "./chunk-WEWW2XJW.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.36",
3
+ "version": "0.5.38",
4
4
  "description": "AgenticMail Enterprise — cloud-hosted AI agent identity, email, auth & compliance for organizations",
5
5
  "type": "module",
6
6
  "bin": {
@@ -143,7 +143,7 @@ export class ApprovalEngine {
143
143
 
144
144
  // Load escalation chains
145
145
  try {
146
- const chains = await this.engineDb.query<any>('SELECT * FROM escalation_chains WHERE enabled = 1');
146
+ const chains = await this.engineDb.query<any>('SELECT * FROM escalation_chains WHERE enabled = TRUE');
147
147
  for (const r of chains) {
148
148
  this.escalationChains.set(r.id, {
149
149
  id: r.id, orgId: r.org_id, name: r.name, description: r.description,
@@ -609,7 +609,7 @@ export class EngineDatabase {
609
609
  }
610
610
 
611
611
  async getAllApprovalPolicies(): Promise<ApprovalPolicy[]> {
612
- const rows = await this.db.all<any>('SELECT * FROM approval_policies WHERE enabled = 1 ORDER BY name');
612
+ const rows = await this.db.all<any>('SELECT * FROM approval_policies WHERE enabled = TRUE ORDER BY name');
613
613
  return rows.map(r => ({
614
614
  id: r.id, name: r.name, description: r.description,
615
615
  triggers: sj(r.triggers), approvers: sj(r.approvers),
@@ -654,7 +654,7 @@ export class EngineDatabase {
654
654
  }
655
655
 
656
656
  async getSsoIntegrationByType(orgId: string, providerType: string): Promise<any | null> {
657
- const row = await this.db.get<any>('SELECT * FROM sso_integrations WHERE org_id = ? AND provider_type = ? AND enabled = 1', [orgId, providerType]);
657
+ const row = await this.db.get<any>('SELECT * FROM sso_integrations WHERE org_id = ? AND provider_type = ? AND enabled = TRUE', [orgId, providerType]);
658
658
  return row ? this.rowToSso(row) : null;
659
659
  }
660
660
 
package/src/engine/dlp.ts CHANGED
@@ -73,7 +73,7 @@ export class DLPEngine {
73
73
  private async loadFromDb(): Promise<void> {
74
74
  if (!this.engineDb) return;
75
75
  try {
76
- const rows = await this.engineDb.query<any>('SELECT * FROM dlp_rules WHERE enabled = 1');
76
+ const rows = await this.engineDb.query<any>('SELECT * FROM dlp_rules WHERE enabled = TRUE');
77
77
  for (const r of rows) {
78
78
  this.rules.set(r.id, {
79
79
  id: r.id, orgId: r.org_id, name: r.name, description: r.description,
@@ -118,7 +118,7 @@ export class GuardrailEngine {
118
118
  private async loadFromDb(): Promise<void> {
119
119
  if (!this.engineDb) return;
120
120
  try {
121
- const rules = await this.engineDb.query<any>('SELECT * FROM anomaly_rules WHERE enabled = 1');
121
+ const rules = await this.engineDb.query<any>('SELECT * FROM anomaly_rules WHERE enabled = TRUE');
122
122
  for (const r of rules) {
123
123
  this.anomalyRules.set(r.id, {
124
124
  id: r.id, orgId: r.org_id, name: r.name, description: r.description,
@@ -143,7 +143,7 @@ export class GuardrailEngine {
143
143
 
144
144
  // Load extended guardrail rules
145
145
  try {
146
- const gRules = await this.engineDb.query<any>('SELECT * FROM guardrail_rules WHERE enabled = 1');
146
+ const gRules = await this.engineDb.query<any>('SELECT * FROM guardrail_rules WHERE enabled = TRUE');
147
147
  for (const r of gRules) {
148
148
  this.guardrailRules.set(r.id, {
149
149
  id: r.id, orgId: r.org_id, name: r.name, description: r.description,
@@ -86,19 +86,10 @@ export function createKnowledgeRoutes(knowledgeBase: KnowledgeBaseEngine) {
86
86
  const docId = c.req.param('docId');
87
87
  const kb = knowledgeBase.getKnowledgeBase(kbId);
88
88
  if (!kb) return c.json({ error: 'Knowledge base not found' }, 404);
89
- // Get chunks from the internal chunks map
90
- const allChunks = (knowledgeBase as any).chunks || new Map();
91
- const docChunks: any[] = [];
92
- if (allChunks instanceof Map) {
93
- allChunks.forEach((chunk: any) => {
94
- if (chunk.documentId === docId) docChunks.push(chunk);
95
- });
96
- } else if (typeof allChunks === 'object') {
97
- for (const [, chunk] of Object.entries(allChunks)) {
98
- if ((chunk as any).documentId === docId) docChunks.push(chunk);
99
- }
100
- }
101
- docChunks.sort((a: any, b: any) => (a.position || 0) - (b.position || 0));
89
+ // Find the document and return its chunks
90
+ const doc = kb.documents?.find((d: any) => d.id === docId);
91
+ if (!doc) return c.json({ error: 'Document not found' }, 404);
92
+ const docChunks = (doc.chunks || []).slice().sort((a: any, b: any) => (a.position || 0) - (b.position || 0));
102
93
  return c.json({ chunks: docChunks, total: docChunks.length });
103
94
  });
104
95
 
@@ -12,12 +12,17 @@ import type { WorkforceManager } from './workforce.js';
12
12
  export function createWorkforceRoutes(workforce: WorkforceManager, opts?: { lifecycle?: any }) {
13
13
  const router = new Hono();
14
14
 
15
+ /** Extract orgId from body > query > JWT payload > fallback */
16
+ function resolveOrgId(c: any, body?: any): string {
17
+ return body?.orgId || c.req.query('orgId') || (c.get?.('jwtPayload') as any)?.orgId || 'AMXK7W9P3E';
18
+ }
19
+
15
20
  // ─── Schedule CRUD ──────────────────────────────────────
16
21
 
17
22
  /** List all schedules for the requesting org */
18
23
  router.get('/schedules', async (c) => {
19
24
  try {
20
- const orgId = c.req.header('X-User-Id') || 'default';
25
+ const orgId = resolveOrgId(c);
21
26
  const schedules = await workforce.getSchedulesByOrg(orgId);
22
27
  return c.json({ schedules, total: schedules.length });
23
28
  } catch (err: any) {
@@ -44,14 +49,12 @@ export function createWorkforceRoutes(workforce: WorkforceManager, opts?: { life
44
49
  if (!body.agentId) {
45
50
  return c.json({ error: 'agentId is required' }, 400);
46
51
  }
47
- if (!body.orgId) {
48
- return c.json({ error: 'orgId is required' }, 400);
49
- }
52
+ const orgId = resolveOrgId(c, body);
50
53
 
51
54
  const schedule = {
52
55
  id: body.id || crypto.randomUUID(),
53
56
  agentId: body.agentId,
54
- orgId: body.orgId,
57
+ orgId,
55
58
  timezone: body.timezone || 'UTC',
56
59
  scheduleType: body.scheduleType,
57
60
  config: body.config,
@@ -146,7 +149,7 @@ export function createWorkforceRoutes(workforce: WorkforceManager, opts?: { life
146
149
  /** Get workforce status for all agents in the org */
147
150
  router.get('/status', async (c) => {
148
151
  try {
149
- const orgId = c.req.header('X-User-Id') || 'default';
152
+ const orgId = resolveOrgId(c);
150
153
  const status = await workforce.getWorkforceStatus(orgId);
151
154
  return c.json(status);
152
155
  } catch (err: any) {
@@ -191,17 +194,15 @@ export function createWorkforceRoutes(workforce: WorkforceManager, opts?: { life
191
194
  if (!body.agentId) {
192
195
  return c.json({ error: 'agentId is required' }, 400);
193
196
  }
194
- if (!body.orgId) {
195
- return c.json({ error: 'orgId is required' }, 400);
196
- }
197
197
  if (!body.title) {
198
198
  return c.json({ error: 'title is required' }, 400);
199
199
  }
200
200
 
201
+ const orgId = resolveOrgId(c, body);
201
202
  const task = {
202
203
  id: body.id || crypto.randomUUID(),
203
204
  agentId: body.agentId,
204
- orgId: body.orgId,
205
+ orgId,
205
206
  type: body.type || 'general',
206
207
  title: body.title,
207
208
  description: body.description || '',
@@ -282,7 +283,7 @@ export function createWorkforceRoutes(workforce: WorkforceManager, opts?: { life
282
283
  /** Extended budget overview, requires lifecycle manager to be configured */
283
284
  router.get('/budget-overview', async (c) => {
284
285
  try {
285
- const orgId = c.req.header('X-User-Id') || 'default';
286
+ const orgId = resolveOrgId(c);
286
287
 
287
288
  if (!opts?.lifecycle?.getBudgetSummary) {
288
289
  return c.json(
@@ -133,7 +133,7 @@ export class WorkforceManager {
133
133
  private async loadFromDb(): Promise<void> {
134
134
  if (!this.engineDb) return;
135
135
  try {
136
- const rows = await this.engineDb.query<any>('SELECT * FROM work_schedules WHERE enabled = 1');
136
+ const rows = await this.engineDb.query<any>('SELECT * FROM work_schedules WHERE enabled = TRUE');
137
137
  for (const r of rows) {
138
138
  const schedule: WorkSchedule = {
139
139
  id: r.id,