@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.
- package/dist/agent-heartbeat-UMTRYIL4.js +510 -0
- package/dist/agent-heartbeat-XJOKJ7XN.js +510 -0
- package/dist/chunk-3FAXFUMK.js +4494 -0
- package/dist/chunk-3ULO6AZ2.js +1224 -0
- package/dist/chunk-7KFJ4IBO.js +3682 -0
- package/dist/chunk-F5KFQC34.js +4457 -0
- package/dist/chunk-NTUFF6XP.js +1224 -0
- package/dist/chunk-XUF2WJRM.js +3685 -0
- package/dist/cli-agent-33ZNJCCK.js +1602 -0
- package/dist/cli-agent-KYGHCO36.js +1602 -0
- package/dist/cli-serve-D4S7YR2S.js +114 -0
- package/dist/cli-serve-QNUAKPMI.js +114 -0
- package/dist/cli.js +3 -3
- package/dist/index.js +3 -3
- package/dist/routes-7VPMCOUY.js +13280 -0
- package/dist/routes-KTVR5FR2.js +13280 -0
- package/dist/runtime-YIM3AGF3.js +45 -0
- package/dist/runtime-ZUCF6OPX.js +45 -0
- package/dist/server-KS4AZZJR.js +15 -0
- package/dist/server-Y5ZRZIBT.js +15 -0
- package/dist/setup-6RBJ2WQU.js +20 -0
- package/dist/setup-Z6ZVNE7V.js +20 -0
- package/package.json +1 -1
- package/src/engine/chat-poller.ts +1 -1
- package/src/engine/messaging-poller.ts +1 -1
- package/src/engine/task-queue.ts +17 -10
- package/src/runtime/gateway.ts +45 -0
- package/src/server.ts +4 -1
|
@@ -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
|
@@ -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({
|
package/src/engine/task-queue.ts
CHANGED
|
@@ -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
|
|
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
|
|
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
|
|
119
|
-
await this.db.run(`CREATE INDEX IF NOT EXISTS
|
|
120
|
-
await this.db.run(`CREATE INDEX IF NOT EXISTS
|
|
121
|
-
await this.db.run(`CREATE INDEX IF NOT EXISTS
|
|
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
|
|
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
|
|
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
|
|
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),
|
package/src/runtime/gateway.ts
CHANGED
|
@@ -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');
|