@agenticmail/enterprise 0.5.48 → 0.5.50
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/chunk-263FEFGL.js +9085 -0
- package/dist/chunk-6T5PE7NL.js +12676 -0
- package/dist/chunk-JFXH5PXO.js +2115 -0
- package/dist/chunk-NUG7SMVQ.js +374 -0
- package/dist/chunk-R3JR6Z3H.js +898 -0
- package/dist/cli.js +1 -1
- package/dist/index.js +737 -5
- package/dist/routes-XLP2NQ3M.js +5783 -0
- package/dist/runtime-NCYXXHGF.js +47 -0
- package/dist/server-U5SUFL4J.js +12 -0
- package/dist/setup-SIJZ4MNG.js +20 -0
- package/dist/skills-75VFQLP7.js +14 -0
- package/package.json +1 -1
- package/src/agenticmail/index.ts +32 -0
- package/src/agenticmail/manager.ts +253 -0
- package/src/agenticmail/providers/google.ts +331 -0
- package/src/agenticmail/providers/index.ts +26 -0
- package/src/agenticmail/providers/microsoft.ts +260 -0
- package/src/agenticmail/types.ts +171 -0
- package/src/engine/skills.ts +4 -257
- package/src/index.ts +5 -0
|
@@ -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-6T5PE7NL.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-JFXH5PXO.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-R3JR6Z3H.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
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BUILTIN_SKILLS,
|
|
3
|
+
PRESET_PROFILES,
|
|
4
|
+
PermissionEngine,
|
|
5
|
+
SKILL_SUITES
|
|
6
|
+
} from "./chunk-NUG7SMVQ.js";
|
|
7
|
+
import "./chunk-MINPSFLF.js";
|
|
8
|
+
import "./chunk-KFQGP6VL.js";
|
|
9
|
+
export {
|
|
10
|
+
BUILTIN_SKILLS,
|
|
11
|
+
PRESET_PROFILES,
|
|
12
|
+
PermissionEngine,
|
|
13
|
+
SKILL_SUITES
|
|
14
|
+
};
|
package/package.json
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgenticMail Enterprise
|
|
3
|
+
*
|
|
4
|
+
* Embedded email & communication system for enterprise agents.
|
|
5
|
+
* No separate server — agents use their org email via OAuth.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import { AgenticMailManager } from './agenticmail/index.js';
|
|
9
|
+
* const mail = new AgenticMailManager({ db: engineDb });
|
|
10
|
+
* await mail.registerAgent({ agentId, email, accessToken, provider: 'microsoft', ... });
|
|
11
|
+
* const provider = mail.getProvider(agentId);
|
|
12
|
+
* await provider.send({ to: 'user@company.com', subject: 'Hello', body: '...' });
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
export { AgenticMailManager } from './manager.js';
|
|
16
|
+
export type { AgenticMailManagerOptions } from './manager.js';
|
|
17
|
+
export { createEmailProvider } from './providers/index.js';
|
|
18
|
+
export { MicrosoftEmailProvider } from './providers/microsoft.js';
|
|
19
|
+
export { GoogleEmailProvider } from './providers/google.js';
|
|
20
|
+
export type {
|
|
21
|
+
IEmailProvider,
|
|
22
|
+
AgentEmailIdentity,
|
|
23
|
+
EmailProvider,
|
|
24
|
+
EmailMessage,
|
|
25
|
+
EmailEnvelope,
|
|
26
|
+
EmailFolder,
|
|
27
|
+
SendEmailOptions,
|
|
28
|
+
SearchCriteria,
|
|
29
|
+
EmailAttachment,
|
|
30
|
+
AgentMessage,
|
|
31
|
+
AgentTask,
|
|
32
|
+
} from './types.js';
|
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AgenticMail Enterprise Manager
|
|
3
|
+
*
|
|
4
|
+
* Central orchestrator that connects agents to their org email.
|
|
5
|
+
* Manages email provider instances per agent and provides the
|
|
6
|
+
* tool handler interface for the enterprise agent system.
|
|
7
|
+
*
|
|
8
|
+
* Architecture:
|
|
9
|
+
* Agent (from org directory via OAuth)
|
|
10
|
+
* → AgenticMailManager.getProvider(agentId)
|
|
11
|
+
* → IEmailProvider (Microsoft Graph / Gmail API)
|
|
12
|
+
* → Org's email system
|
|
13
|
+
*
|
|
14
|
+
* No separate AgenticMail server. No API keys. No relay setup.
|
|
15
|
+
* The agent IS the org identity.
|
|
16
|
+
*/
|
|
17
|
+
|
|
18
|
+
import type { EngineDatabase } from '../engine/db-adapter.js';
|
|
19
|
+
import type {
|
|
20
|
+
IEmailProvider, AgentEmailIdentity, EmailProvider,
|
|
21
|
+
AgentMessage, AgentTask,
|
|
22
|
+
} from './types.js';
|
|
23
|
+
import { createEmailProvider } from './providers/index.js';
|
|
24
|
+
|
|
25
|
+
export interface AgenticMailManagerOptions {
|
|
26
|
+
db?: EngineDatabase;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export class AgenticMailManager {
|
|
30
|
+
private providers = new Map<string, IEmailProvider>();
|
|
31
|
+
private identities = new Map<string, AgentEmailIdentity>();
|
|
32
|
+
private db?: EngineDatabase;
|
|
33
|
+
|
|
34
|
+
constructor(opts?: AgenticMailManagerOptions) {
|
|
35
|
+
this.db = opts?.db;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
setDb(db: EngineDatabase): void {
|
|
39
|
+
this.db = db;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// ─── Agent Registration ─────────────────────────────
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Register an agent's email identity from the org's OAuth/SSO.
|
|
46
|
+
* Called when an agent is created or when its OAuth token is refreshed.
|
|
47
|
+
*/
|
|
48
|
+
async registerAgent(identity: AgentEmailIdentity): Promise<void> {
|
|
49
|
+
this.identities.set(identity.agentId, identity);
|
|
50
|
+
|
|
51
|
+
// Create and connect the email provider
|
|
52
|
+
const provider = createEmailProvider(identity.provider);
|
|
53
|
+
await provider.connect(identity);
|
|
54
|
+
this.providers.set(identity.agentId, provider);
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Unregister an agent (on deletion or token revocation).
|
|
59
|
+
*/
|
|
60
|
+
async unregisterAgent(agentId: string): Promise<void> {
|
|
61
|
+
const provider = this.providers.get(agentId);
|
|
62
|
+
if (provider) {
|
|
63
|
+
await provider.disconnect().catch(() => {});
|
|
64
|
+
this.providers.delete(agentId);
|
|
65
|
+
}
|
|
66
|
+
this.identities.delete(agentId);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Get the email provider for an agent.
|
|
71
|
+
* Throws if agent is not registered.
|
|
72
|
+
*/
|
|
73
|
+
getProvider(agentId: string): IEmailProvider {
|
|
74
|
+
const provider = this.providers.get(agentId);
|
|
75
|
+
if (!provider) throw new Error(`Agent ${agentId} has no email provider registered. Ensure the agent has been connected via org OAuth.`);
|
|
76
|
+
return provider;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Get the email identity for an agent.
|
|
81
|
+
*/
|
|
82
|
+
getIdentity(agentId: string): AgentEmailIdentity | undefined {
|
|
83
|
+
return this.identities.get(agentId);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/**
|
|
87
|
+
* Check if an agent has email access.
|
|
88
|
+
*/
|
|
89
|
+
hasEmail(agentId: string): boolean {
|
|
90
|
+
return this.providers.has(agentId);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// ─── Inter-Agent Messaging ──────────────────────────
|
|
94
|
+
// These use the enterprise DB directly, not email.
|
|
95
|
+
// Agents in the same org can message each other without email.
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Send a message from one agent to another (internal, no email).
|
|
99
|
+
*/
|
|
100
|
+
async sendAgentMessage(from: string, to: string, subject: string, body: string, priority: 'normal' | 'high' | 'urgent' = 'normal'): Promise<AgentMessage> {
|
|
101
|
+
const msg: AgentMessage = {
|
|
102
|
+
id: crypto.randomUUID(),
|
|
103
|
+
from,
|
|
104
|
+
to,
|
|
105
|
+
subject,
|
|
106
|
+
body,
|
|
107
|
+
priority,
|
|
108
|
+
createdAt: new Date().toISOString(),
|
|
109
|
+
read: false,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
if (this.db) {
|
|
113
|
+
await this.db.execute(
|
|
114
|
+
`INSERT INTO agent_messages (id, from_agent, to_agent, subject, body, priority, created_at, read)
|
|
115
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, 0)`,
|
|
116
|
+
[msg.id, msg.from, msg.to, msg.subject, msg.body, msg.priority, msg.createdAt]
|
|
117
|
+
).catch(() => {});
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
return msg;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Get unread messages for an agent.
|
|
125
|
+
*/
|
|
126
|
+
async getAgentMessages(agentId: string, opts?: { unreadOnly?: boolean; limit?: number }): Promise<AgentMessage[]> {
|
|
127
|
+
if (!this.db) return [];
|
|
128
|
+
try {
|
|
129
|
+
let sql = 'SELECT * FROM agent_messages WHERE to_agent = ?';
|
|
130
|
+
const params: any[] = [agentId];
|
|
131
|
+
if (opts?.unreadOnly) {
|
|
132
|
+
sql += ' AND read = 0';
|
|
133
|
+
}
|
|
134
|
+
sql += ' ORDER BY created_at DESC LIMIT ?';
|
|
135
|
+
params.push(opts?.limit || 20);
|
|
136
|
+
|
|
137
|
+
const rows = await this.db.query<any>(sql, params);
|
|
138
|
+
return rows.map((r: any) => ({
|
|
139
|
+
id: r.id,
|
|
140
|
+
from: r.from_agent,
|
|
141
|
+
to: r.to_agent,
|
|
142
|
+
subject: r.subject,
|
|
143
|
+
body: r.body,
|
|
144
|
+
priority: r.priority,
|
|
145
|
+
createdAt: r.created_at,
|
|
146
|
+
read: !!r.read,
|
|
147
|
+
}));
|
|
148
|
+
} catch {
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// ─── Task Management ────────────────────────────────
|
|
154
|
+
// Tasks also use the enterprise DB directly.
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Create a task assigned to an agent.
|
|
158
|
+
*/
|
|
159
|
+
async createTask(assigner: string, assignee: string, title: string, description?: string, priority: 'low' | 'normal' | 'high' | 'urgent' = 'normal'): Promise<AgentTask> {
|
|
160
|
+
const now = new Date().toISOString();
|
|
161
|
+
const task: AgentTask = {
|
|
162
|
+
id: crypto.randomUUID(),
|
|
163
|
+
assigner,
|
|
164
|
+
assignee,
|
|
165
|
+
title,
|
|
166
|
+
description,
|
|
167
|
+
status: 'pending',
|
|
168
|
+
priority,
|
|
169
|
+
createdAt: now,
|
|
170
|
+
updatedAt: now,
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
if (this.db) {
|
|
174
|
+
await this.db.execute(
|
|
175
|
+
`INSERT INTO agent_tasks (id, assigner, assignee, title, description, status, priority, created_at, updated_at)
|
|
176
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)`,
|
|
177
|
+
[task.id, task.assigner, task.assignee, task.title, task.description || null, task.status, task.priority, task.createdAt, task.updatedAt]
|
|
178
|
+
).catch(() => {});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
return task;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/**
|
|
185
|
+
* Get tasks for an agent.
|
|
186
|
+
*/
|
|
187
|
+
async getAgentTasks(agentId: string, direction: 'incoming' | 'outgoing' = 'incoming', status?: string): Promise<AgentTask[]> {
|
|
188
|
+
if (!this.db) return [];
|
|
189
|
+
try {
|
|
190
|
+
const col = direction === 'incoming' ? 'assignee' : 'assigner';
|
|
191
|
+
let sql = `SELECT * FROM agent_tasks WHERE ${col} = ?`;
|
|
192
|
+
const params: any[] = [agentId];
|
|
193
|
+
if (status) {
|
|
194
|
+
sql += ' AND status = ?';
|
|
195
|
+
params.push(status);
|
|
196
|
+
}
|
|
197
|
+
sql += ' ORDER BY created_at DESC LIMIT 50';
|
|
198
|
+
|
|
199
|
+
const rows = await this.db.query<any>(sql, params);
|
|
200
|
+
return rows.map((r: any) => ({
|
|
201
|
+
id: r.id,
|
|
202
|
+
assigner: r.assigner,
|
|
203
|
+
assignee: r.assignee,
|
|
204
|
+
title: r.title,
|
|
205
|
+
description: r.description,
|
|
206
|
+
status: r.status,
|
|
207
|
+
priority: r.priority,
|
|
208
|
+
result: r.result ? JSON.parse(r.result) : undefined,
|
|
209
|
+
createdAt: r.created_at,
|
|
210
|
+
updatedAt: r.updated_at,
|
|
211
|
+
}));
|
|
212
|
+
} catch {
|
|
213
|
+
return [];
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/**
|
|
218
|
+
* Update task status.
|
|
219
|
+
*/
|
|
220
|
+
async updateTask(taskId: string, updates: { status?: string; result?: any }): Promise<void> {
|
|
221
|
+
if (!this.db) return;
|
|
222
|
+
const sets: string[] = ['updated_at = ?'];
|
|
223
|
+
const params: any[] = [new Date().toISOString()];
|
|
224
|
+
if (updates.status) { sets.push('status = ?'); params.push(updates.status); }
|
|
225
|
+
if (updates.result !== undefined) { sets.push('result = ?'); params.push(JSON.stringify(updates.result)); }
|
|
226
|
+
params.push(taskId);
|
|
227
|
+
await this.db.execute(`UPDATE agent_tasks SET ${sets.join(', ')} WHERE id = ?`, params).catch(() => {});
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// ─── Lifecycle ──────────────────────────────────────
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Get all registered agents and their email status.
|
|
234
|
+
*/
|
|
235
|
+
getRegisteredAgents(): { agentId: string; email: string; provider: EmailProvider }[] {
|
|
236
|
+
const agents: { agentId: string; email: string; provider: EmailProvider }[] = [];
|
|
237
|
+
for (const [agentId, identity] of this.identities) {
|
|
238
|
+
agents.push({ agentId, email: identity.email, provider: identity.provider });
|
|
239
|
+
}
|
|
240
|
+
return agents;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Shutdown — disconnect all providers.
|
|
245
|
+
*/
|
|
246
|
+
async shutdown(): Promise<void> {
|
|
247
|
+
for (const provider of this.providers.values()) {
|
|
248
|
+
await provider.disconnect().catch(() => {});
|
|
249
|
+
}
|
|
250
|
+
this.providers.clear();
|
|
251
|
+
this.identities.clear();
|
|
252
|
+
}
|
|
253
|
+
}
|