@agenticmail/enterprise 0.5.204 → 0.5.206

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,45 @@
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-F5KFQC34.js";
18
+ import {
19
+ PROVIDER_REGISTRY,
20
+ listAllProviders,
21
+ resolveApiKeyForProvider,
22
+ resolveProvider
23
+ } from "./chunk-UF3ZJMJO.js";
24
+ import "./chunk-KFQGP6VL.js";
25
+ export {
26
+ AgentRuntime,
27
+ EmailChannel,
28
+ FollowUpScheduler,
29
+ PROVIDER_REGISTRY,
30
+ SessionManager,
31
+ SubAgentManager,
32
+ ToolRegistry,
33
+ callLLM,
34
+ createAgentRuntime,
35
+ createNoopHooks,
36
+ createRuntimeHooks,
37
+ estimateMessageTokens,
38
+ estimateTokens,
39
+ executeTool,
40
+ listAllProviders,
41
+ resolveApiKeyForProvider,
42
+ resolveProvider,
43
+ runAgentLoop,
44
+ toolsToDefinitions
45
+ };
@@ -0,0 +1,45 @@
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-3FAXFUMK.js";
18
+ import {
19
+ PROVIDER_REGISTRY,
20
+ listAllProviders,
21
+ resolveApiKeyForProvider,
22
+ resolveProvider
23
+ } from "./chunk-UF3ZJMJO.js";
24
+ import "./chunk-KFQGP6VL.js";
25
+ export {
26
+ AgentRuntime,
27
+ EmailChannel,
28
+ FollowUpScheduler,
29
+ PROVIDER_REGISTRY,
30
+ SessionManager,
31
+ SubAgentManager,
32
+ ToolRegistry,
33
+ callLLM,
34
+ createAgentRuntime,
35
+ createNoopHooks,
36
+ createRuntimeHooks,
37
+ estimateMessageTokens,
38
+ estimateTokens,
39
+ executeTool,
40
+ listAllProviders,
41
+ resolveApiKeyForProvider,
42
+ resolveProvider,
43
+ runAgentLoop,
44
+ toolsToDefinitions
45
+ };
@@ -0,0 +1,15 @@
1
+ import {
2
+ createServer
3
+ } from "./chunk-7KFJ4IBO.js";
4
+ import "./chunk-OF4MUWWS.js";
5
+ import "./chunk-UF3ZJMJO.js";
6
+ import "./chunk-3OC6RH7W.js";
7
+ import "./chunk-2DDKGTD6.js";
8
+ import "./chunk-YVK6F5OD.js";
9
+ import "./chunk-MKRNEM5A.js";
10
+ import "./chunk-DRXMYYKN.js";
11
+ import "./chunk-6WSX7QXF.js";
12
+ import "./chunk-KFQGP6VL.js";
13
+ export {
14
+ createServer
15
+ };
@@ -0,0 +1,15 @@
1
+ import {
2
+ createServer
3
+ } from "./chunk-XUF2WJRM.js";
4
+ import "./chunk-OF4MUWWS.js";
5
+ import "./chunk-UF3ZJMJO.js";
6
+ import "./chunk-3OC6RH7W.js";
7
+ import "./chunk-2DDKGTD6.js";
8
+ import "./chunk-YVK6F5OD.js";
9
+ import "./chunk-MKRNEM5A.js";
10
+ import "./chunk-DRXMYYKN.js";
11
+ import "./chunk-6WSX7QXF.js";
12
+ import "./chunk-KFQGP6VL.js";
13
+ export {
14
+ createServer
15
+ };
@@ -0,0 +1,20 @@
1
+ import {
2
+ promptCompanyInfo,
3
+ promptDatabase,
4
+ promptDeployment,
5
+ promptDomain,
6
+ promptRegistration,
7
+ provision,
8
+ runSetupWizard
9
+ } from "./chunk-3ULO6AZ2.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
+ };
@@ -0,0 +1,20 @@
1
+ import {
2
+ promptCompanyInfo,
3
+ promptDatabase,
4
+ promptDeployment,
5
+ promptDomain,
6
+ promptRegistration,
7
+ provision,
8
+ runSetupWizard
9
+ } from "./chunk-NTUFF6XP.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.204",
3
+ "version": "0.5.206",
4
4
  "description": "AgenticMail Enterprise — cloud-hosted AI agent identity, email, auth & compliance for organizations",
5
5
  "type": "module",
6
6
  "bin": {
@@ -750,7 +750,7 @@ export class ChatPoller {
750
750
  messageText: msg.text,
751
751
  };
752
752
 
753
- const url = `http://${agent.host}:${agent.port}/api/runtime/chat`;
753
+ const url = `http://${agent.host}:${agent.port}/api/engine/runtime/chat`;
754
754
 
755
755
  try {
756
756
  const resp = await fetch(url, {
@@ -437,7 +437,7 @@ export class MessagingPoller {
437
437
  }).catch(() => {});
438
438
  }
439
439
  try {
440
- var resp = await fetch(`http://${agent.host}:${agent.port}/api/runtime/chat`, {
440
+ var resp = await fetch(`http://${agent.host}:${agent.port}/api/engine/runtime/chat`, {
441
441
  method: 'POST',
442
442
  headers: { 'Content-Type': 'application/json' },
443
443
  body: JSON.stringify({
@@ -84,7 +84,7 @@ export class TaskQueueManager {
84
84
  if (this.initialized) return;
85
85
  if (this.db) {
86
86
  try {
87
- await this.db.run(`CREATE TABLE IF NOT EXISTS task_queue (
87
+ await this.db.run(`CREATE TABLE IF NOT EXISTS task_pipeline (
88
88
  id TEXT PRIMARY KEY,
89
89
  org_id TEXT NOT NULL,
90
90
  assigned_to TEXT NOT NULL,
@@ -98,7 +98,7 @@ export class TaskQueueManager {
98
98
  status TEXT NOT NULL DEFAULT 'created',
99
99
  priority TEXT NOT NULL DEFAULT 'normal',
100
100
  progress INTEGER NOT NULL DEFAULT 0,
101
- created_at TEXT NOT NULL DEFAULT (datetime('now')),
101
+ created_at TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
102
102
  assigned_at TEXT,
103
103
  started_at TEXT,
104
104
  completed_at TEXT,
@@ -115,13 +115,14 @@ export class TaskQueueManager {
115
115
  tokens_used INTEGER NOT NULL DEFAULT 0,
116
116
  cost_usd REAL NOT NULL DEFAULT 0
117
117
  )`);
118
- await this.db.run(`CREATE INDEX IF NOT EXISTS idx_task_queue_org ON task_queue(org_id)`);
119
- await this.db.run(`CREATE INDEX IF NOT EXISTS idx_task_queue_agent ON task_queue(assigned_to)`);
120
- await this.db.run(`CREATE INDEX IF NOT EXISTS idx_task_queue_status ON task_queue(status)`);
121
- await this.db.run(`CREATE INDEX IF NOT EXISTS idx_task_queue_created ON task_queue(created_at)`);
118
+ await this.db.run(`CREATE INDEX IF NOT EXISTS idx_task_pipeline_org ON task_pipeline(org_id)`);
119
+ await this.db.run(`CREATE INDEX IF NOT EXISTS idx_task_pipeline_agent ON task_pipeline(assigned_to)`);
120
+ await this.db.run(`CREATE INDEX IF NOT EXISTS idx_task_pipeline_status ON task_pipeline(status)`);
121
+ await this.db.run(`CREATE INDEX IF NOT EXISTS idx_task_pipeline_created ON task_pipeline(created_at)`);
122
122
 
123
123
  // Load recent tasks into memory
124
- const rows = await this.db.all(`SELECT * FROM task_queue WHERE status IN ('created','assigned','in_progress') OR created_at > datetime('now', '-24 hours') ORDER BY created_at DESC LIMIT 500`);
124
+ const cutoff = new Date(Date.now() - 24 * 60 * 60 * 1000).toISOString();
125
+ const rows = await this.db.all(`SELECT * FROM task_pipeline WHERE status IN ('created','assigned','in_progress') OR created_at > ? ORDER BY created_at DESC LIMIT 500`, [cutoff]);
125
126
  for (const row of rows || []) {
126
127
  this.tasks.set(row.id, this.rowToTask(row));
127
128
  }
@@ -262,7 +263,7 @@ export class TaskQueueManager {
262
263
  if (this.db) {
263
264
  try {
264
265
  const rows = await this.db.all(
265
- `SELECT * FROM task_queue WHERE org_id = ? ORDER BY created_at DESC LIMIT ? OFFSET ?`,
266
+ `SELECT * FROM task_pipeline WHERE org_id = ? ORDER BY created_at DESC LIMIT ? OFFSET ?`,
266
267
  [orgId, limit, offset]
267
268
  );
268
269
  return (rows || []).map((r: any) => this.rowToTask(r));
@@ -304,14 +305,20 @@ export class TaskQueueManager {
304
305
  private async persist(task: TaskRecord): Promise<void> {
305
306
  if (!this.db) return;
306
307
  try {
307
- await this.db.run(`INSERT OR REPLACE INTO task_queue (
308
+ await this.db.run(`INSERT INTO task_pipeline (
308
309
  id, org_id, assigned_to, assigned_to_name, created_by, created_by_name,
309
310
  title, description, category, tags, status, priority, progress,
310
311
  created_at, assigned_at, started_at, completed_at,
311
312
  estimated_duration_ms, actual_duration_ms, result, error,
312
313
  parent_task_id, related_agent_ids, session_id,
313
314
  model, fallback_model, model_used, tokens_used, cost_usd
314
- ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)`, [
315
+ ) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)
316
+ ON CONFLICT (id) DO UPDATE SET
317
+ status=EXCLUDED.status, priority=EXCLUDED.priority, progress=EXCLUDED.progress,
318
+ assigned_at=EXCLUDED.assigned_at, started_at=EXCLUDED.started_at, completed_at=EXCLUDED.completed_at,
319
+ actual_duration_ms=EXCLUDED.actual_duration_ms, result=EXCLUDED.result, error=EXCLUDED.error,
320
+ model_used=EXCLUDED.model_used, tokens_used=EXCLUDED.tokens_used, cost_usd=EXCLUDED.cost_usd,
321
+ session_id=EXCLUDED.session_id, title=EXCLUDED.title, description=EXCLUDED.description`, [
315
322
  task.id, task.orgId, task.assignedTo, task.assignedToName,
316
323
  task.createdBy, task.createdByName,
317
324
  task.title, task.description, task.category, JSON.stringify(task.tags),
@@ -245,6 +245,51 @@ export function createRuntimeGateway(config: GatewayConfig): Hono {
245
245
 
246
246
  // ─── Inbound Email Hook ──────────────────────────
247
247
 
248
+ // ─── Chat dispatch (from enterprise messaging/chat pollers) ──
249
+ app.post('/chat', async function(c) {
250
+ try {
251
+ var body = await c.req.json();
252
+ // Find or create a session for this chat context
253
+ var source = body.source || body.spaceName || 'unknown';
254
+ var spaceId = body.spaceId || body.chatId || 'default';
255
+ var sessionTag = source + ':' + spaceId;
256
+
257
+ // Look for existing session with this tag
258
+ var sessions = await runtime.listSessions();
259
+ var existing = sessions.find(function(s: any) { return s.tag === sessionTag && s.status === 'active'; });
260
+ var session: any;
261
+
262
+ if (existing) {
263
+ session = existing;
264
+ } else {
265
+ // Create new session
266
+ session = await runtime.createSession({
267
+ tag: sessionTag,
268
+ metadata: { source: source, spaceId: spaceId, senderName: body.senderName, isDM: body.isDM },
269
+ });
270
+ }
271
+
272
+ // Send message to the session
273
+ await runtime.sendMessage(session.id, body.messageText || body.message || '', {
274
+ senderName: body.senderName,
275
+ senderEmail: body.senderEmail,
276
+ source: source,
277
+ isDM: body.isDM,
278
+ isManager: body.isManager,
279
+ priority: body.priority,
280
+ messageId: body.messageId,
281
+ isCustomer: body.isCustomer,
282
+ customerSystemPrompt: body.customerSystemPrompt,
283
+ restrictTools: body.restrictTools,
284
+ });
285
+
286
+ return c.json({ ok: true, sessionId: session.id });
287
+ } catch (err: any) {
288
+ console.error('[runtime] /chat error:', err.message);
289
+ return c.json({ error: err.message }, 500);
290
+ }
291
+ });
292
+
248
293
  app.post('/hooks/inbound', async function(c) {
249
294
  try {
250
295
  var body = await c.req.json();
package/src/server.ts CHANGED
@@ -240,10 +240,13 @@ export function createServer(config: ServerConfig): ServerInstance {
240
240
  return next();
241
241
  }
242
242
 
243
- // Skip auth for runtime/chat — internal dispatch from enterprise to agent process
243
+ // Skip auth for runtime/chat and runtime/hooks — internal dispatch from enterprise to agent process
244
244
  if (c.req.path.includes('/runtime/chat') && c.req.method === 'POST') {
245
245
  return next();
246
246
  }
247
+ if (c.req.path.includes('/runtime/hooks/') && c.req.method === 'POST') {
248
+ return next();
249
+ }
247
250
 
248
251
  // Check API key first
249
252
  const apiKeyHeader = c.req.header('X-API-Key');