@agenticmail/enterprise 0.5.322 → 0.5.324
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-BBINFNL4.js +510 -0
- package/dist/chunk-CQYLRIQ3.js +25938 -0
- package/dist/chunk-GYB2WHMN.js +5101 -0
- package/dist/chunk-KN3T3CTD.js +4929 -0
- package/dist/chunk-SVSLIQYN.js +1519 -0
- package/dist/cli-agent-USMKX7WN.js +2473 -0
- package/dist/cli-serve-7JQ4FVUQ.js +260 -0
- package/dist/cli.js +3 -3
- package/dist/dashboard/app.js +4 -1
- package/dist/dashboard/components/icons.js +1 -0
- package/dist/dashboard/pages/agent-detail/index.js +25 -3
- package/dist/dashboard/pages/agents.js +30 -1
- package/dist/dashboard/pages/cluster.js +181 -0
- package/dist/index.js +4 -4
- package/dist/routes-XYR2RNEC.js +92 -0
- package/dist/runtime-ZOC337DD.js +45 -0
- package/dist/server-7NT4LMSQ.js +28 -0
- package/dist/setup-6NUSB4XO.js +20 -0
- package/logs/cloudflared-error.log +10 -0
- package/logs/enterprise-out.log +4 -0
- package/package.json +1 -1
- package/src/cli-agent.ts +33 -1
- package/src/dashboard/app.js +4 -1
- package/src/dashboard/components/icons.js +1 -0
- package/src/dashboard/pages/agent-detail/index.js +25 -3
- package/src/dashboard/pages/agents.js +30 -1
- package/src/dashboard/pages/cluster.js +181 -0
- package/src/engine/cluster.ts +265 -0
- package/src/engine/routes.ts +45 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
activity,
|
|
3
|
+
agentStatus,
|
|
4
|
+
approvals,
|
|
5
|
+
cluster,
|
|
6
|
+
commBus,
|
|
7
|
+
communityRegistry,
|
|
8
|
+
compliance,
|
|
9
|
+
configGen,
|
|
10
|
+
databaseManager,
|
|
11
|
+
deployer,
|
|
12
|
+
dlp,
|
|
13
|
+
engine,
|
|
14
|
+
getChatPoller,
|
|
15
|
+
getEmailPoller,
|
|
16
|
+
getMessagingPoller,
|
|
17
|
+
guardrails,
|
|
18
|
+
hierarchyManager,
|
|
19
|
+
init_routes,
|
|
20
|
+
journal,
|
|
21
|
+
knowledgeBase,
|
|
22
|
+
knowledgeContribution,
|
|
23
|
+
lifecycle,
|
|
24
|
+
memoryManager,
|
|
25
|
+
mountRuntimeApp,
|
|
26
|
+
onboarding,
|
|
27
|
+
orgIntegrations,
|
|
28
|
+
permissionEngine,
|
|
29
|
+
policyEngine,
|
|
30
|
+
policyImporter,
|
|
31
|
+
setEngineDb,
|
|
32
|
+
setRuntime,
|
|
33
|
+
skillUpdater,
|
|
34
|
+
storageManager,
|
|
35
|
+
tenants,
|
|
36
|
+
vault,
|
|
37
|
+
workforce
|
|
38
|
+
} from "./chunk-CQYLRIQ3.js";
|
|
39
|
+
import "./chunk-Z7NVD3OQ.js";
|
|
40
|
+
import "./chunk-VSBC4SWO.js";
|
|
41
|
+
import "./chunk-AF3WSNVX.js";
|
|
42
|
+
import "./chunk-74ZCQKYU.js";
|
|
43
|
+
import "./chunk-Z6K5FKAB.js";
|
|
44
|
+
import "./chunk-C6JP5NR6.js";
|
|
45
|
+
import "./chunk-BQM7MBPS.js";
|
|
46
|
+
import "./chunk-3UAFHUEC.js";
|
|
47
|
+
import "./chunk-6C5PKREN.js";
|
|
48
|
+
import "./chunk-3FMK32KQ.js";
|
|
49
|
+
import "./chunk-YDD5TC5Q.js";
|
|
50
|
+
import "./chunk-FLQ5FLHW.js";
|
|
51
|
+
import "./chunk-WUAWWKTN.js";
|
|
52
|
+
import "./chunk-ZGYVXYQQ.js";
|
|
53
|
+
import "./chunk-22U7TZPN.js";
|
|
54
|
+
import "./chunk-KFQGP6VL.js";
|
|
55
|
+
init_routes();
|
|
56
|
+
export {
|
|
57
|
+
activity,
|
|
58
|
+
agentStatus,
|
|
59
|
+
approvals,
|
|
60
|
+
cluster,
|
|
61
|
+
commBus,
|
|
62
|
+
communityRegistry,
|
|
63
|
+
compliance,
|
|
64
|
+
configGen,
|
|
65
|
+
databaseManager,
|
|
66
|
+
deployer,
|
|
67
|
+
dlp,
|
|
68
|
+
engine as engineRoutes,
|
|
69
|
+
getChatPoller,
|
|
70
|
+
getEmailPoller,
|
|
71
|
+
getMessagingPoller,
|
|
72
|
+
guardrails,
|
|
73
|
+
hierarchyManager,
|
|
74
|
+
journal,
|
|
75
|
+
knowledgeBase,
|
|
76
|
+
knowledgeContribution,
|
|
77
|
+
lifecycle,
|
|
78
|
+
memoryManager,
|
|
79
|
+
mountRuntimeApp,
|
|
80
|
+
onboarding,
|
|
81
|
+
orgIntegrations,
|
|
82
|
+
permissionEngine,
|
|
83
|
+
policyEngine,
|
|
84
|
+
policyImporter,
|
|
85
|
+
setEngineDb,
|
|
86
|
+
setRuntime,
|
|
87
|
+
skillUpdater,
|
|
88
|
+
storageManager,
|
|
89
|
+
tenants,
|
|
90
|
+
vault,
|
|
91
|
+
workforce
|
|
92
|
+
};
|
|
@@ -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-KN3T3CTD.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,28 @@
|
|
|
1
|
+
import {
|
|
2
|
+
createServer
|
|
3
|
+
} from "./chunk-GYB2WHMN.js";
|
|
4
|
+
import "./chunk-DJBCRQTD.js";
|
|
5
|
+
import "./chunk-UF3ZJMJO.js";
|
|
6
|
+
import "./chunk-CQYLRIQ3.js";
|
|
7
|
+
import "./chunk-Z7NVD3OQ.js";
|
|
8
|
+
import "./chunk-VSBC4SWO.js";
|
|
9
|
+
import "./chunk-AF3WSNVX.js";
|
|
10
|
+
import "./chunk-74ZCQKYU.js";
|
|
11
|
+
import "./chunk-Z6K5FKAB.js";
|
|
12
|
+
import "./chunk-C6JP5NR6.js";
|
|
13
|
+
import "./chunk-BQM7MBPS.js";
|
|
14
|
+
import "./chunk-3UAFHUEC.js";
|
|
15
|
+
import "./chunk-6C5PKREN.js";
|
|
16
|
+
import "./chunk-3FMK32KQ.js";
|
|
17
|
+
import "./chunk-YDD5TC5Q.js";
|
|
18
|
+
import "./chunk-37ABTUFU.js";
|
|
19
|
+
import "./chunk-NU657BBQ.js";
|
|
20
|
+
import "./chunk-PGAU3W3M.js";
|
|
21
|
+
import "./chunk-FLQ5FLHW.js";
|
|
22
|
+
import "./chunk-WUAWWKTN.js";
|
|
23
|
+
import "./chunk-ZGYVXYQQ.js";
|
|
24
|
+
import "./chunk-22U7TZPN.js";
|
|
25
|
+
import "./chunk-KFQGP6VL.js";
|
|
26
|
+
export {
|
|
27
|
+
createServer
|
|
28
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import {
|
|
2
|
+
promptCompanyInfo,
|
|
3
|
+
promptDatabase,
|
|
4
|
+
promptDeployment,
|
|
5
|
+
promptDomain,
|
|
6
|
+
promptRegistration,
|
|
7
|
+
provision,
|
|
8
|
+
runSetupWizard
|
|
9
|
+
} from "./chunk-SVSLIQYN.js";
|
|
10
|
+
import "./chunk-4EKXYIJF.js";
|
|
11
|
+
import "./chunk-KFQGP6VL.js";
|
|
12
|
+
export {
|
|
13
|
+
promptCompanyInfo,
|
|
14
|
+
promptDatabase,
|
|
15
|
+
promptDeployment,
|
|
16
|
+
promptDomain,
|
|
17
|
+
promptRegistration,
|
|
18
|
+
provision,
|
|
19
|
+
runSetupWizard
|
|
20
|
+
};
|
|
@@ -59,3 +59,13 @@
|
|
|
59
59
|
2026-03-05 06:31:11: 2026-03-05T05:31:11Z INF Registered tunnel connection connIndex=3 connection=3b74716b-204c-459d-b533-31e1307e1ea8 event=0 ip=198.41.200.53 location=atl11 protocol=quic
|
|
60
60
|
2026-03-05 06:35:14: 2026-03-05T05:35:14Z ERR error="unexpected EOF" connIndex=3 event=1 ingressRule=0 originService=http://localhost:3100
|
|
61
61
|
2026-03-05 06:35:14: 2026-03-05T05:35:14Z ERR Request failed error="unexpected EOF" connIndex=3 dest=https://enterprise.agenticmail.io/api/engine/task-pipeline/stream event=0 ip=198.41.200.53 type=http
|
|
62
|
+
2026-03-05 06:59:24: 2026-03-05T05:59:24Z ERR error="unexpected EOF" connIndex=3 event=1 ingressRule=0 originService=http://localhost:3100
|
|
63
|
+
2026-03-05 06:59:24: 2026-03-05T05:59:24Z ERR Request failed error="unexpected EOF" connIndex=3 dest=https://enterprise.agenticmail.io/api/engine/task-pipeline/stream event=0 ip=198.41.200.53 type=http
|
|
64
|
+
2026-03-05 06:59:40: 2026-03-05T05:59:40Z ERR error="unexpected EOF" connIndex=3 event=1 ingressRule=0 originService=http://localhost:3100
|
|
65
|
+
2026-03-05 06:59:40: 2026-03-05T05:59:40Z ERR Request failed error="unexpected EOF" connIndex=3 dest=https://enterprise.agenticmail.io/api/engine/task-pipeline/stream event=0 ip=198.41.200.53 type=http
|
|
66
|
+
2026-03-05 07:00:43: 2026-03-05T06:00:43Z ERR error="stream 13 canceled by remote with error code 0" connIndex=3 event=1 ingressRule=0 originService=http://localhost:3100
|
|
67
|
+
2026-03-05 07:00:43: 2026-03-05T06:00:43Z ERR Request failed error="stream 13 canceled by remote with error code 0" connIndex=3 dest=https://enterprise.agenticmail.io/api/engine/task-pipeline/stream event=0 ip=198.41.200.53 type=http
|
|
68
|
+
2026-03-05 07:01:07: 2026-03-05T06:01:07Z ERR error="unexpected EOF" connIndex=3 event=1 ingressRule=0 originService=http://localhost:3100
|
|
69
|
+
2026-03-05 07:01:07: 2026-03-05T06:01:07Z ERR Request failed error="unexpected EOF" connIndex=3 dest=https://enterprise.agenticmail.io/api/engine/agent-status-stream?agentId=3eecd57d-03ae-440d-8945-5b35f43a8d90 event=0 ip=198.41.200.53 type=http
|
|
70
|
+
2026-03-05 07:06:07: 2026-03-05T06:06:07Z ERR error="unexpected EOF" connIndex=3 event=1 ingressRule=0 originService=http://localhost:3100
|
|
71
|
+
2026-03-05 07:06:07: 2026-03-05T06:06:07Z ERR Request failed error="unexpected EOF" connIndex=3 dest=https://enterprise.agenticmail.io/api/engine/agent-status-stream?agentId=3eecd57d-03ae-440d-8945-5b35f43a8d90 event=0 ip=198.41.200.53 type=http
|
package/logs/enterprise-out.log
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
1
|
2026-03-05 06:30:17: Loaded config from /Users/ope/Desktop/projects/agenticmail/enterprise/.env
|
|
2
2
|
2026-03-05 06:31:08: Loaded config from /Users/ope/Desktop/projects/agenticmail/enterprise/.env
|
|
3
3
|
2026-03-05 06:35:14: Loaded config from /Users/ope/Desktop/projects/agenticmail/enterprise/.env
|
|
4
|
+
2026-03-05 06:59:24: Loaded config from /Users/ope/Desktop/projects/agenticmail/enterprise/.env
|
|
5
|
+
2026-03-05 06:59:40: Loaded config from /Users/ope/Desktop/projects/agenticmail/enterprise/.env
|
|
6
|
+
2026-03-05 07:01:07: Loaded config from /Users/ope/Desktop/projects/agenticmail/enterprise/.env
|
|
7
|
+
2026-03-05 07:06:08: Loaded config from /Users/ope/Desktop/projects/agenticmail/enterprise/.env
|
package/package.json
CHANGED
package/src/cli-agent.ts
CHANGED
|
@@ -686,11 +686,43 @@ export async function runAgent(_args: string[]) {
|
|
|
686
686
|
};
|
|
687
687
|
// Mark online immediately
|
|
688
688
|
_reportStatus({ status: 'idle', clockedIn: false, activeSessions: 0, currentActivity: null });
|
|
689
|
-
// Heartbeat every 30s
|
|
689
|
+
// Heartbeat every 30s (status + cluster)
|
|
690
|
+
const _agentPort = parseInt(process.env.PORT || '3101');
|
|
691
|
+
const _hostname = process.env.HOSTNAME || process.env.WORKER_HOST || 'localhost';
|
|
690
692
|
setInterval(() => {
|
|
691
693
|
const sessions = (runtime as any).activeSessions?.size || 0;
|
|
692
694
|
_reportStatus({ status: sessions > 0 ? 'online' : 'idle', activeSessions: sessions });
|
|
695
|
+
// Cluster heartbeat (if registered)
|
|
696
|
+
fetch(`${ENTERPRISE_URL}/api/engine/cluster/heartbeat/${process.env.WORKER_NODE_ID || AGENT_ID}`, {
|
|
697
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
698
|
+
body: JSON.stringify({ agents: [AGENT_ID] }),
|
|
699
|
+
}).catch(() => {});
|
|
693
700
|
}, 30_000).unref();
|
|
701
|
+
// Register as cluster worker node (if WORKER_NODE_ID is set)
|
|
702
|
+
if (process.env.WORKER_NODE_ID) {
|
|
703
|
+
const os = await import('os');
|
|
704
|
+
fetch(`${ENTERPRISE_URL}/api/engine/cluster/register`, {
|
|
705
|
+
method: 'POST', headers: { 'Content-Type': 'application/json' },
|
|
706
|
+
body: JSON.stringify({
|
|
707
|
+
nodeId: process.env.WORKER_NODE_ID,
|
|
708
|
+
name: process.env.WORKER_NAME || os.hostname(),
|
|
709
|
+
host: _hostname,
|
|
710
|
+
port: _agentPort,
|
|
711
|
+
platform: process.platform,
|
|
712
|
+
arch: process.arch,
|
|
713
|
+
cpuCount: os.cpus().length,
|
|
714
|
+
memoryMb: Math.round(os.totalmem() / 1024 / 1024),
|
|
715
|
+
version: process.env.npm_package_version || 'unknown',
|
|
716
|
+
agents: [AGENT_ID],
|
|
717
|
+
capabilities: [
|
|
718
|
+
process.env.WORKER_CAPABILITIES || '',
|
|
719
|
+
process.platform === 'darwin' ? 'voice' : '',
|
|
720
|
+
'browser',
|
|
721
|
+
].filter(Boolean),
|
|
722
|
+
}),
|
|
723
|
+
}).then(() => console.log(`[cluster] Registered as worker node: ${process.env.WORKER_NODE_ID}`))
|
|
724
|
+
.catch((e) => console.warn(`[cluster] Registration failed: ${e.message}`));
|
|
725
|
+
}
|
|
694
726
|
// Expose reporter for runtime to use
|
|
695
727
|
(runtime as any)._reportStatus = _reportStatus;
|
|
696
728
|
|
package/src/dashboard/app.js
CHANGED
|
@@ -31,6 +31,7 @@ import { DatabaseAccessPage } from './pages/database-access.js';
|
|
|
31
31
|
import { OrganizationsPage } from './pages/organizations.js';
|
|
32
32
|
import { RolesPage } from './pages/roles.js';
|
|
33
33
|
import { MemoryTransferPage } from './pages/memory-transfer.js';
|
|
34
|
+
import { ClusterPage } from './pages/cluster.js';
|
|
34
35
|
|
|
35
36
|
// ─── Toast System ────────────────────────────────────────
|
|
36
37
|
let toastId = 0;
|
|
@@ -252,7 +253,7 @@ function App() {
|
|
|
252
253
|
setUser(d.user);
|
|
253
254
|
// Immediately restrict permissions for client org users (before async fetch)
|
|
254
255
|
if (d.user.clientOrgId) {
|
|
255
|
-
setPermissions({ dashboard: true, agents: true, roles: true, skills: true, 'community-skills': true, 'skill-connections': true, 'database-access': true, knowledge: true, 'knowledge-contributions': true, 'memory-transfer': true, approvals: true, 'org-chart': true, 'task-pipeline': true, workforce: true, messages: true, guardrails: true, journal: true, activity: true, dlp: true, compliance: true, vault: true, audit: true, settings: true });
|
|
256
|
+
setPermissions({ dashboard: true, agents: true, roles: true, skills: true, 'community-skills': true, 'skill-connections': true, 'database-access': true, knowledge: true, 'knowledge-contributions': true, 'memory-transfer': true, approvals: true, 'org-chart': true, 'task-pipeline': true, cluster: true, workforce: true, messages: true, guardrails: true, journal: true, activity: true, dlp: true, compliance: true, vault: true, audit: true, settings: true });
|
|
256
257
|
}
|
|
257
258
|
// Then fetch computed permissions for the definitive set
|
|
258
259
|
apiCall('/me/permissions').then(function(p) { if (p && p.permissions) setPermissions(p.permissions); }).catch(function() {});
|
|
@@ -404,6 +405,7 @@ function App() {
|
|
|
404
405
|
{ section: 'Operations', items: [
|
|
405
406
|
{ id: 'org-chart', icon: I.orgChart, label: 'Org Chart' },
|
|
406
407
|
{ id: 'task-pipeline', icon: I.workflow, label: 'Task Pipeline' },
|
|
408
|
+
{ id: 'cluster', icon: I.server, label: 'Cluster' },
|
|
407
409
|
{ id: 'workforce', icon: I.clock, label: 'Workforce' },
|
|
408
410
|
{ id: 'messages', icon: I.messages, label: 'Messages' },
|
|
409
411
|
{ id: 'guardrails', icon: I.guardrails, label: 'Guardrails' },
|
|
@@ -447,6 +449,7 @@ function App() {
|
|
|
447
449
|
organizations: OrganizationsPage,
|
|
448
450
|
roles: RolesPage,
|
|
449
451
|
'memory-transfer': MemoryTransferPage,
|
|
452
|
+
cluster: ClusterPage,
|
|
450
453
|
};
|
|
451
454
|
|
|
452
455
|
const navigateToAgent = (agentId) => { _setSelectedAgentId(agentId); history.pushState(null, '', '/dashboard/agents/' + agentId); };
|
|
@@ -58,6 +58,7 @@ chevronRight: () => h('svg', S, h('polyline', { points: '9 18 15 12 9 6' })),
|
|
|
58
58
|
chevronDown: () => h('svg', S, h('polyline', { points: '6 9 12 15 18 9' })),
|
|
59
59
|
mail: () => h('svg', S, h('path', { d: 'M4 4h16c1.1 0 2 .9 2 2v12c0 1.1-.9 2-2 2H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2z' }), h('polyline', { points: '22,6 12,13 2,6' })),
|
|
60
60
|
building: () => h('svg', S, h('path', { d: 'M3 21h18M3 10h18M3 7l9-4 9 4M4 10v11M20 10v11M8 14v.01M12 14v.01M16 14v.01M8 18v.01M12 18v.01M16 18v.01' })),
|
|
61
|
+
server: () => h('svg', S, h('rect', { x: 2, y: 2, width: 20, height: 8, rx: 2, ry: 2 }), h('rect', { x: 2, y: 14, width: 20, height: 8, rx: 2, ry: 2 }), h('line', { x1: 6, y1: 6, x2: 6.01, y2: 6 }), h('line', { x1: 6, y1: 18, x2: 6.01, y2: 18 })),
|
|
61
62
|
brain: () => h('svg', S, h('path', { d: 'M9.5 2a3.5 3.5 0 00-3.21 4.87A3.5 3.5 0 004 10.5a3.5 3.5 0 002.81 3.43A3.5 3.5 0 009.5 18h1V2z' }), h('path', { d: 'M14.5 2a3.5 3.5 0 013.21 4.87A3.5 3.5 0 0120 10.5a3.5 3.5 0 01-2.81 3.43A3.5 3.5 0 0114.5 18h-1V2z' }), h('path', { d: 'M12 2v16' }), h('path', { d: 'M4.93 7.5h2.57M16.5 7.5h2.57M7 13h3M14 13h3' })),
|
|
62
63
|
edit: () => h('svg', S, h('path', { d: 'M11 4H4a2 2 0 0 0-2 2v14a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-7' }), h('path', { d: 'M18.5 2.5a2.121 2.121 0 0 1 3 3L12 15l-4 1 1-4 9.5-9.5z' })),
|
|
63
64
|
};
|
|
@@ -103,14 +103,35 @@ export function AgentDetailPage(props) {
|
|
|
103
103
|
|
|
104
104
|
useEffect(function() { load(); }, [agentId]);
|
|
105
105
|
|
|
106
|
+
// ─── Real-Time Status from Agent Process ────────────────
|
|
107
|
+
var [liveStatus, setLiveStatus] = useState(null);
|
|
108
|
+
useEffect(function() {
|
|
109
|
+
var es = new EventSource('/api/engine/agent-status-stream?agentId=' + encodeURIComponent(agentId));
|
|
110
|
+
es.onmessage = function(ev) {
|
|
111
|
+
try {
|
|
112
|
+
var d = JSON.parse(ev.data);
|
|
113
|
+
if (d.type === 'status' && d.agentId === agentId) { setLiveStatus(d); }
|
|
114
|
+
} catch(e) {}
|
|
115
|
+
};
|
|
116
|
+
es.onerror = function() { /* reconnects automatically */ };
|
|
117
|
+
return function() { es.close(); };
|
|
118
|
+
}, [agentId]);
|
|
119
|
+
|
|
106
120
|
// ─── Derived Values ─────────────────────────────────────
|
|
107
121
|
|
|
108
122
|
var ea = engineAgent || {};
|
|
109
123
|
var a = agent || {};
|
|
110
124
|
var config = ea.config || {};
|
|
111
125
|
var identity = config.identity || {};
|
|
112
|
-
|
|
113
|
-
var
|
|
126
|
+
// Prefer live process status over DB state
|
|
127
|
+
var liveState = liveStatus ? liveStatus.status : null;
|
|
128
|
+
var dbState = ea.state || ea.status || a.status || 'unknown';
|
|
129
|
+
var state = liveState || dbState;
|
|
130
|
+
// Map live statuses: online→running, idle→idle, offline→stopped, error→error
|
|
131
|
+
if (state === 'online') state = 'running';
|
|
132
|
+
if (state === 'idle') state = 'idle';
|
|
133
|
+
if (state === 'offline') state = 'stopped';
|
|
134
|
+
var stateColor = { running: 'success', active: 'success', idle: 'info', deploying: 'info', starting: 'info', provisioning: 'info', degraded: 'warning', error: 'danger', stopped: 'neutral', draft: 'neutral', ready: 'primary' }[state] || 'neutral';
|
|
114
135
|
var displayName = identity.name || config.name || config.displayName || a.name || 'Unnamed Agent';
|
|
115
136
|
var displayEmail = identity.email || config.email || a.email || '';
|
|
116
137
|
var avatarUrl = identity.avatar && identity.avatar.length > 2 ? identity.avatar : null;
|
|
@@ -175,7 +196,8 @@ export function AgentDetailPage(props) {
|
|
|
175
196
|
h('div', { style: { flex: 1, minWidth: 0 } },
|
|
176
197
|
h('div', { style: { display: 'flex', alignItems: 'center', gap: 8, flexWrap: 'wrap' } },
|
|
177
198
|
h('h1', { style: { fontSize: 20, fontWeight: 700, margin: 0 } }, displayName),
|
|
178
|
-
h('span', { className: 'badge badge-' + stateColor, style: { textTransform: 'capitalize' } }, state)
|
|
199
|
+
h('span', { className: 'badge badge-' + stateColor, style: { textTransform: 'capitalize' } }, state),
|
|
200
|
+
liveStatus && liveStatus.currentActivity && h('span', { style: { fontSize: 11, color: 'var(--text-muted)', fontStyle: 'italic' } }, liveStatus.currentActivity.detail || liveStatus.currentActivity.type)
|
|
179
201
|
),
|
|
180
202
|
h('div', { style: { display: 'flex', alignItems: 'center', gap: 12, marginTop: 4 } },
|
|
181
203
|
displayEmail && h('span', { style: { fontFamily: 'var(--font-mono, monospace)', fontSize: 12, color: 'var(--text-muted)' } }, displayEmail),
|
|
@@ -1132,6 +1132,25 @@ export function AgentsPage({ onSelectAgent }) {
|
|
|
1132
1132
|
var orgCtx = useOrgContext();
|
|
1133
1133
|
const [agents, setAgents] = useState([]);
|
|
1134
1134
|
const [creating, setCreating] = useState(false);
|
|
1135
|
+
const [liveStatuses, setLiveStatuses] = useState({});
|
|
1136
|
+
|
|
1137
|
+
// Subscribe to real-time agent status
|
|
1138
|
+
useEffect(function() {
|
|
1139
|
+
var es = new EventSource('/api/engine/agent-status-stream');
|
|
1140
|
+
es.onmessage = function(ev) {
|
|
1141
|
+
try {
|
|
1142
|
+
var d = JSON.parse(ev.data);
|
|
1143
|
+
if (d.type === 'status' && d.agentId) {
|
|
1144
|
+
setLiveStatuses(function(prev) {
|
|
1145
|
+
var next = Object.assign({}, prev);
|
|
1146
|
+
next[d.agentId] = d;
|
|
1147
|
+
return next;
|
|
1148
|
+
});
|
|
1149
|
+
}
|
|
1150
|
+
} catch(e) {}
|
|
1151
|
+
};
|
|
1152
|
+
return function() { es.close(); };
|
|
1153
|
+
}, []);
|
|
1135
1154
|
|
|
1136
1155
|
const perms = app.permissions || '*';
|
|
1137
1156
|
const allowedAgents = perms === '*' ? '*' : (perms._allowedAgents || '*');
|
|
@@ -1190,7 +1209,17 @@ export function AgentsPage({ onSelectAgent }) {
|
|
|
1190
1209
|
h('td', null, h('strong', { style: { cursor: 'pointer', color: 'var(--accent-text)' }, onClick: () => onSelectAgent && onSelectAgent(a.id) }, a.name)),
|
|
1191
1210
|
h('td', null, h('span', { style: { fontFamily: 'var(--font-mono)', fontSize: 12 } }, a.email || '-')),
|
|
1192
1211
|
h('td', null, h('span', { className: 'badge badge-neutral' }, a.role || 'agent')),
|
|
1193
|
-
h('td', null,
|
|
1212
|
+
h('td', null, (function() {
|
|
1213
|
+
var live = liveStatuses[a.id];
|
|
1214
|
+
var st = live ? live.status : null;
|
|
1215
|
+
var label = st === 'online' ? 'running' : st === 'idle' ? 'idle' : st === 'offline' ? 'stopped' : st === 'error' ? 'error' : (a.status || 'active');
|
|
1216
|
+
var color = { running: 'success', idle: 'info', stopped: 'neutral', error: 'danger', active: 'success', archived: 'neutral' }[label] || 'warning';
|
|
1217
|
+
var activity = live && live.currentActivity ? live.currentActivity.detail || live.currentActivity.type : null;
|
|
1218
|
+
return h(Fragment, null,
|
|
1219
|
+
h('span', { className: 'badge badge-' + color, style: { textTransform: 'capitalize' } }, label),
|
|
1220
|
+
activity && h('span', { style: { fontSize: 10, color: 'var(--text-muted)', marginLeft: 6, fontStyle: 'italic' } }, activity)
|
|
1221
|
+
);
|
|
1222
|
+
})()),
|
|
1194
1223
|
h('td', { style: { fontSize: 12, color: 'var(--text-muted)' } }, a.createdAt ? new Date(a.createdAt).toLocaleDateString() : '-'),
|
|
1195
1224
|
h('td', null,
|
|
1196
1225
|
h('div', { style: { display: 'flex', gap: 4 } },
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { h, useState, useEffect, Fragment, useApp, engineCall } from '../components/utils.js';
|
|
2
|
+
import { I } from '../components/icons.js';
|
|
3
|
+
|
|
4
|
+
export function ClusterPage() {
|
|
5
|
+
var app = useApp();
|
|
6
|
+
var toast = app.toast;
|
|
7
|
+
var [nodes, setNodes] = useState([]);
|
|
8
|
+
var [stats, setStats] = useState(null);
|
|
9
|
+
var [loading, setLoading] = useState(true);
|
|
10
|
+
|
|
11
|
+
var load = function() {
|
|
12
|
+
engineCall('/cluster/nodes').then(function(d) {
|
|
13
|
+
setNodes(d.nodes || []);
|
|
14
|
+
setStats(d.stats || null);
|
|
15
|
+
setLoading(false);
|
|
16
|
+
}).catch(function() { setLoading(false); });
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
useEffect(function() { load(); }, []);
|
|
20
|
+
|
|
21
|
+
// Real-time updates via SSE
|
|
22
|
+
useEffect(function() {
|
|
23
|
+
var es = new EventSource('/api/engine/cluster/stream');
|
|
24
|
+
es.onmessage = function(ev) {
|
|
25
|
+
try {
|
|
26
|
+
var d = JSON.parse(ev.data);
|
|
27
|
+
if (d.type === 'node') {
|
|
28
|
+
setNodes(function(prev) {
|
|
29
|
+
var idx = prev.findIndex(function(n) { return n.nodeId === d.nodeId; });
|
|
30
|
+
var next = prev.slice();
|
|
31
|
+
if (idx >= 0) {
|
|
32
|
+
if (d.event === 'offline') { next[idx] = Object.assign({}, next[idx], { status: 'offline' }); }
|
|
33
|
+
else { next[idx] = d; }
|
|
34
|
+
} else if (d.event === 'register' || d.event === 'snapshot') {
|
|
35
|
+
next.push(d);
|
|
36
|
+
}
|
|
37
|
+
return next;
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
} catch(e) {}
|
|
41
|
+
};
|
|
42
|
+
return function() { es.close(); };
|
|
43
|
+
}, []);
|
|
44
|
+
|
|
45
|
+
var removeNode = function(nodeId) {
|
|
46
|
+
if (!confirm('Remove worker node "' + nodeId + '"? Agents on it will become unreachable.')) return;
|
|
47
|
+
engineCall('/cluster/nodes/' + nodeId, { method: 'DELETE' }).then(function() {
|
|
48
|
+
toast('Node removed', 'success');
|
|
49
|
+
load();
|
|
50
|
+
}).catch(function(e) { toast(e.message, 'error'); });
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
var statusColor = function(s) {
|
|
54
|
+
return { online: 'success', degraded: 'warning', offline: 'neutral' }[s] || 'neutral';
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
var formatBytes = function(mb) {
|
|
58
|
+
if (mb >= 1024) return (mb / 1024).toFixed(1) + ' GB';
|
|
59
|
+
return mb + ' MB';
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
var timeSince = function(iso) {
|
|
63
|
+
if (!iso) return 'never';
|
|
64
|
+
var s = Math.floor((Date.now() - new Date(iso).getTime()) / 1000);
|
|
65
|
+
if (s < 60) return s + 's ago';
|
|
66
|
+
if (s < 3600) return Math.floor(s / 60) + 'm ago';
|
|
67
|
+
if (s < 86400) return Math.floor(s / 3600) + 'h ago';
|
|
68
|
+
return Math.floor(s / 86400) + 'd ago';
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
if (loading) return h('div', { style: { padding: 40, textAlign: 'center', color: 'var(--text-muted)' } }, 'Loading cluster...');
|
|
72
|
+
|
|
73
|
+
return h(Fragment, null,
|
|
74
|
+
h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'center', marginBottom: 20 } },
|
|
75
|
+
h('div', null,
|
|
76
|
+
h('h1', { style: { fontSize: 20, fontWeight: 700 } }, 'Cluster'),
|
|
77
|
+
h('p', { style: { color: 'var(--text-muted)', fontSize: 13 } }, 'Manage worker nodes running agents across multiple machines')
|
|
78
|
+
),
|
|
79
|
+
h('button', { className: 'btn btn-secondary btn-sm', onClick: load }, I.refresh(), ' Refresh')
|
|
80
|
+
),
|
|
81
|
+
|
|
82
|
+
// Stats cards
|
|
83
|
+
stats && h('div', { style: { display: 'grid', gridTemplateColumns: 'repeat(auto-fit, minmax(160px, 1fr))', gap: 12, marginBottom: 20 } },
|
|
84
|
+
h('div', { className: 'card' }, h('div', { className: 'card-body', style: { padding: 16 } },
|
|
85
|
+
h('div', { style: { fontSize: 24, fontWeight: 700 } }, stats.totalNodes),
|
|
86
|
+
h('div', { style: { fontSize: 12, color: 'var(--text-muted)' } }, 'Total Nodes')
|
|
87
|
+
)),
|
|
88
|
+
h('div', { className: 'card' }, h('div', { className: 'card-body', style: { padding: 16 } },
|
|
89
|
+
h('div', { style: { fontSize: 24, fontWeight: 700, color: 'var(--accent-green)' } }, stats.onlineNodes),
|
|
90
|
+
h('div', { style: { fontSize: 12, color: 'var(--text-muted)' } }, 'Online')
|
|
91
|
+
)),
|
|
92
|
+
h('div', { className: 'card' }, h('div', { className: 'card-body', style: { padding: 16 } },
|
|
93
|
+
h('div', { style: { fontSize: 24, fontWeight: 700 } }, stats.totalAgents),
|
|
94
|
+
h('div', { style: { fontSize: 12, color: 'var(--text-muted)' } }, 'Running Agents')
|
|
95
|
+
)),
|
|
96
|
+
h('div', { className: 'card' }, h('div', { className: 'card-body', style: { padding: 16 } },
|
|
97
|
+
h('div', { style: { fontSize: 24, fontWeight: 700 } }, stats.totalCpus),
|
|
98
|
+
h('div', { style: { fontSize: 12, color: 'var(--text-muted)' } }, 'Total CPUs')
|
|
99
|
+
)),
|
|
100
|
+
h('div', { className: 'card' }, h('div', { className: 'card-body', style: { padding: 16 } },
|
|
101
|
+
h('div', { style: { fontSize: 24, fontWeight: 700 } }, formatBytes(stats.totalMemoryMb)),
|
|
102
|
+
h('div', { style: { fontSize: 12, color: 'var(--text-muted)' } }, 'Total Memory')
|
|
103
|
+
))
|
|
104
|
+
),
|
|
105
|
+
|
|
106
|
+
// Nodes
|
|
107
|
+
nodes.length === 0
|
|
108
|
+
? h('div', { className: 'card' }, h('div', { className: 'card-body' },
|
|
109
|
+
h('div', { className: 'empty-state' },
|
|
110
|
+
I.server(),
|
|
111
|
+
h('h3', null, 'No worker nodes'),
|
|
112
|
+
h('p', null, 'Worker nodes auto-register when you deploy agents to remote machines.'),
|
|
113
|
+
h('div', { style: { marginTop: 16, padding: 16, background: 'var(--bg-secondary)', borderRadius: 8, textAlign: 'left', maxWidth: 500, margin: '16px auto' } },
|
|
114
|
+
h('div', { style: { fontWeight: 600, marginBottom: 8 } }, 'How to add a worker node:'),
|
|
115
|
+
h('ol', { style: { paddingLeft: 20, fontSize: 13, color: 'var(--text-muted)', lineHeight: 1.8 } },
|
|
116
|
+
h('li', null, 'Install on the remote machine: ', h('code', null, 'npm i -g @agenticmail/enterprise')),
|
|
117
|
+
h('li', null, 'Set environment variables:'),
|
|
118
|
+
h('pre', { style: { background: 'var(--bg-primary)', padding: 8, borderRadius: 4, fontSize: 11, overflow: 'auto', margin: '4px 0' } },
|
|
119
|
+
'ENTERPRISE_URL=https://your-dashboard.agenticmail.io\nWORKER_NODE_ID=mac-mini-2\nWORKER_NAME="Office Mac Mini"\nDATABASE_URL=postgres://...'
|
|
120
|
+
),
|
|
121
|
+
h('li', null, 'Start agent: ', h('code', null, 'agenticmail-enterprise agent --id <agent-id>')),
|
|
122
|
+
h('li', null, 'The node will auto-register and appear here')
|
|
123
|
+
)
|
|
124
|
+
)
|
|
125
|
+
)
|
|
126
|
+
))
|
|
127
|
+
: h('div', { style: { display: 'grid', gap: 12 } },
|
|
128
|
+
nodes.map(function(node) {
|
|
129
|
+
return h('div', { key: node.nodeId, className: 'card' },
|
|
130
|
+
h('div', { className: 'card-body', style: { padding: 16 } },
|
|
131
|
+
h('div', { style: { display: 'flex', justifyContent: 'space-between', alignItems: 'flex-start' } },
|
|
132
|
+
h('div', null,
|
|
133
|
+
h('div', { style: { display: 'flex', alignItems: 'center', gap: 8 } },
|
|
134
|
+
h('span', { style: { fontSize: 16, fontWeight: 700 } }, node.name || node.nodeId),
|
|
135
|
+
h('span', { className: 'badge badge-' + statusColor(node.status), style: { textTransform: 'capitalize' } }, node.status)
|
|
136
|
+
),
|
|
137
|
+
h('div', { style: { fontSize: 12, color: 'var(--text-muted)', marginTop: 4 } },
|
|
138
|
+
node.host + ':' + node.port, ' | ',
|
|
139
|
+
node.platform + '/' + node.arch, ' | ',
|
|
140
|
+
'v' + node.version
|
|
141
|
+
)
|
|
142
|
+
),
|
|
143
|
+
h('button', { className: 'btn btn-ghost btn-sm', onClick: function() { removeNode(node.nodeId); }, title: 'Remove' },
|
|
144
|
+
I.trash()
|
|
145
|
+
)
|
|
146
|
+
),
|
|
147
|
+
// Resources
|
|
148
|
+
h('div', { style: { display: 'flex', gap: 20, marginTop: 12 } },
|
|
149
|
+
h('div', null,
|
|
150
|
+
h('div', { style: { fontSize: 11, color: 'var(--text-muted)' } }, 'CPUs'),
|
|
151
|
+
h('div', { style: { fontWeight: 600 } }, node.cpuCount)
|
|
152
|
+
),
|
|
153
|
+
h('div', null,
|
|
154
|
+
h('div', { style: { fontSize: 11, color: 'var(--text-muted)' } }, 'Memory'),
|
|
155
|
+
h('div', { style: { fontWeight: 600 } }, formatBytes(node.memoryMb))
|
|
156
|
+
),
|
|
157
|
+
h('div', null,
|
|
158
|
+
h('div', { style: { fontSize: 11, color: 'var(--text-muted)' } }, 'Agents'),
|
|
159
|
+
h('div', { style: { fontWeight: 600 } }, node.agents ? node.agents.length : 0)
|
|
160
|
+
),
|
|
161
|
+
h('div', null,
|
|
162
|
+
h('div', { style: { fontSize: 11, color: 'var(--text-muted)' } }, 'Last Heartbeat'),
|
|
163
|
+
h('div', { style: { fontWeight: 600, color: node.status === 'online' ? 'var(--accent-green)' : 'var(--text-muted)' } }, timeSince(node.lastHeartbeat))
|
|
164
|
+
)
|
|
165
|
+
),
|
|
166
|
+
// Capabilities
|
|
167
|
+
node.capabilities && node.capabilities.length > 0 && h('div', { style: { display: 'flex', gap: 4, marginTop: 8 } },
|
|
168
|
+
node.capabilities.map(function(c) {
|
|
169
|
+
return h('span', { key: c, className: 'badge badge-neutral', style: { fontSize: 10 } }, c);
|
|
170
|
+
})
|
|
171
|
+
),
|
|
172
|
+
// Agent list
|
|
173
|
+
node.agents && node.agents.length > 0 && h('div', { style: { marginTop: 8, fontSize: 12, color: 'var(--text-muted)' } },
|
|
174
|
+
'Running: ', node.agents.join(', ')
|
|
175
|
+
)
|
|
176
|
+
)
|
|
177
|
+
);
|
|
178
|
+
})
|
|
179
|
+
)
|
|
180
|
+
);
|
|
181
|
+
}
|