@agenticmail/enterprise 0.5.251 → 0.5.253

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-4IUA4QZE.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-WXXG3LYY.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-J6QPL5WN.js";
10
+ import "./chunk-ULRBF2T7.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,7 @@
1
+ import {
2
+ TaskQueueManager
3
+ } from "./chunk-BIPFPIDH.js";
4
+ import "./chunk-KFQGP6VL.js";
5
+ export {
6
+ TaskQueueManager
7
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticmail/enterprise",
3
- "version": "0.5.251",
3
+ "version": "0.5.253",
4
4
  "description": "AgenticMail Enterprise — cloud-hosted AI agent identity, email, auth & compliance for organizations",
5
5
  "type": "module",
6
6
  "bin": {
package/src/cli-agent.ts CHANGED
@@ -675,6 +675,23 @@ export async function runAgent(_args: string[]) {
675
675
  const identity = agent.config?.identity || {};
676
676
 
677
677
  const { buildTaskPrompt, buildScheduleInfo } = await import('./system-prompts/index.js');
678
+
679
+ // Record task in pipeline BEFORE spawning
680
+ let pipelineTaskId: string | undefined;
681
+ try {
682
+ pipelineTaskId = await beforeSpawn(taskQueue, {
683
+ orgId: agent.org_id || '',
684
+ agentId: agentId,
685
+ agentName: agentName,
686
+ createdBy: 'api',
687
+ createdByName: 'API Task',
688
+ task: body.task,
689
+ model: (config.model ? `${config.model.provider}/${config.model.modelId}` : undefined) || process.env.AGENTICMAIL_MODEL,
690
+ sessionId: undefined,
691
+ source: 'api',
692
+ });
693
+ } catch (e: any) { /* non-fatal */ }
694
+
678
695
  const session = await runtime.spawnSession({
679
696
  agentId: agentId,
680
697
  message: body.task,
@@ -686,8 +703,28 @@ export async function runAgent(_args: string[]) {
686
703
  }),
687
704
  });
688
705
 
689
- console.log(`[task] Session ${session.id} created for task: "${body.task.slice(0, 80)}"`);
690
- return c.json({ ok: true, sessionId: session.id, taskId: body.taskId });
706
+ // Mark task as in progress
707
+ if (pipelineTaskId) {
708
+ markInProgress(taskQueue, pipelineTaskId, { sessionId: session.id }).catch(() => {});
709
+ }
710
+
711
+ // Record task completion when session finishes
712
+ if (pipelineTaskId) {
713
+ runtime.onSessionComplete(session.id, async (result: any) => {
714
+ const usage = result?.usage || {};
715
+ afterSpawn(taskQueue, {
716
+ taskId: pipelineTaskId!,
717
+ status: result?.error ? 'failed' : 'completed',
718
+ error: result?.error?.message || result?.error,
719
+ modelUsed: result?.model || config.model,
720
+ tokensUsed: (usage.inputTokens || 0) + (usage.outputTokens || 0),
721
+ costUsd: usage.costUsd || usage.cost || 0,
722
+ }).catch(() => {});
723
+ });
724
+ }
725
+
726
+ console.log(`[task] Session ${session.id} created for task: "${body.task.slice(0, 80)}"${pipelineTaskId ? ` (pipeline: ${pipelineTaskId.slice(0, 8)})` : ''}`);
727
+ return c.json({ ok: true, sessionId: session.id, taskId: body.taskId || pipelineTaskId });
691
728
  } catch (err: any) {
692
729
  console.error(`[task] Error: ${err.message}`);
693
730
  return c.json({ error: err.message }, 500);
@@ -416,8 +416,8 @@ function McpServersSection() {
416
416
  // Agent assignment
417
417
  agents.length > 0 && h('div', { className: 'form-group', style: { marginTop: 16 } },
418
418
  h('label', { className: 'form-label', style: { display: 'flex', alignItems: 'center' } }, 'Agent Access', h(HelpButton, { label: 'Agent Access' },
419
- h('p', null, 'Choose which agents can use this MCP server\'s tools. If none are selected, ALL agents can use it.'),
420
- h('p', { style: { marginTop: 8 } }, 'Use this to restrict sensitive tools (like database access) to specific agents only.')
419
+ h('p', null, 'Choose which agents can use this MCP server\'s tools. You must select at least one agent no agent has access until explicitly granted.'),
420
+ h('p', { style: { marginTop: 8 } }, 'This ensures sensitive tools (like database access) are never accidentally exposed to the wrong agent.')
421
421
  )),
422
422
  h('div', { style: { display: 'flex', flexWrap: 'wrap', gap: 6 } },
423
423
  agents.map(function(a) {
@@ -441,8 +441,8 @@ function McpServersSection() {
441
441
  ),
442
442
  h('div', { style: { fontSize: 11, color: 'var(--text-muted)', marginTop: 4 } },
443
443
  form.assignedAgents && form.assignedAgents.length > 0
444
- ? form.assignedAgents.length + ' agent(s) selected — only they can use this server'
445
- : 'No agents selected — all agents can use this server'
444
+ ? form.assignedAgents.length + ' agent(s) selected'
445
+ : 'No agents selected — no agent can use this server yet'
446
446
  )
447
447
  )
448
448
  ),
@@ -213,10 +213,10 @@ export class McpProcessManager extends EventEmitter {
213
213
  for (const [id, state] of Array.from(this.servers)) {
214
214
  if (state.status !== 'connected') continue;
215
215
 
216
- // Check agent assignment
217
- if (agentId && state.config.assignedAgents?.length) {
218
- if (!state.config.assignedAgents.includes(agentId)) continue;
219
- }
216
+ // Check agent assignment — empty/missing means NO agents have access
217
+ if (!state.config.assignedAgents?.length) continue;
218
+ if (agentId && !state.config.assignedAgents.includes(agentId)) continue;
219
+ if (!agentId) continue; // anonymous callers get nothing
220
220
 
221
221
  for (const tool of state.tools) {
222
222
  tools.push({ ...tool, serverId: id, serverName: state.config.name });
@@ -241,9 +241,8 @@ export class McpProcessManager extends EventEmitter {
241
241
  // Find which server owns this tool
242
242
  for (const [_id, state] of Array.from(this.servers)) {
243
243
  if (state.status !== 'connected') continue;
244
- if (agentId && state.config.assignedAgents?.length) {
245
- if (!state.config.assignedAgents.includes(agentId)) continue;
246
- }
244
+ if (!state.config.assignedAgents?.length) continue;
245
+ if (!agentId || !state.config.assignedAgents.includes(agentId)) continue;
247
246
 
248
247
  const tool = state.tools.find(t => t.name === toolName);
249
248
  if (!tool) continue;
@@ -522,6 +522,28 @@ export function createRuntimeHooks(deps: HookDependencies): RuntimeHooks {
522
522
  } catch (err: any) {
523
523
  console.warn(`[hooks] Failed to persist compaction summary: ${err?.message}`);
524
524
  }
525
+
526
+ // Link compaction to task pipeline — update task progress with compaction event
527
+ try {
528
+ var { TaskQueueManager } = await import('../engine/task-queue.js');
529
+ var tq = new TaskQueueManager();
530
+ (tq as any).db = deps.engineDb;
531
+ await tq.init();
532
+ // Find active task for this session
533
+ var tasks = await tq.listTasks({ orgId: deps.orgId, status: 'in_progress' });
534
+ var sessionTask = tasks.find(function(t: any) { return t.sessionId === sessionId; });
535
+ if (sessionTask) {
536
+ await tq.updateTask(sessionTask.id, {
537
+ activityLog: [...(sessionTask.activityLog || []), {
538
+ ts: new Date().toISOString(),
539
+ type: 'compaction',
540
+ agent: agentId,
541
+ detail: `Context compacted (${summary.length} chars summary). Agent continues from compacted state.`,
542
+ }],
543
+ });
544
+ console.log(`[hooks] Task ${sessionTask.id.slice(0, 8)} updated with compaction event`);
545
+ }
546
+ } catch { /* non-fatal */ }
525
547
  },
526
548
  };
527
549
  }