@agenticmail/enterprise 0.5.323 → 0.5.325

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.
Files changed (43) hide show
  1. package/dist/agent-heartbeat-BBINFNL4.js +510 -0
  2. package/dist/agent-heartbeat-UF2RKKS2.js +510 -0
  3. package/dist/chunk-4DBWU3P5.js +4929 -0
  4. package/dist/chunk-CQYLRIQ3.js +25938 -0
  5. package/dist/chunk-GYB2WHMN.js +5101 -0
  6. package/dist/chunk-KN3T3CTD.js +4929 -0
  7. package/dist/chunk-SVSLIQYN.js +1519 -0
  8. package/dist/chunk-VBTHTPZ6.js +26055 -0
  9. package/dist/chunk-WD72IOF2.js +5101 -0
  10. package/dist/chunk-ZGFDTW4H.js +1519 -0
  11. package/dist/cli-agent-USMKX7WN.js +2473 -0
  12. package/dist/cli-agent-ZIIFI77N.js +2473 -0
  13. package/dist/cli-serve-7JQ4FVUQ.js +260 -0
  14. package/dist/cli-serve-MLR4KAE2.js +260 -0
  15. package/dist/cli.js +3 -3
  16. package/dist/dashboard/app.js +4 -1
  17. package/dist/dashboard/components/icons.js +1 -0
  18. package/dist/dashboard/docs/cluster.html +285 -0
  19. package/dist/dashboard/pages/agent-detail/index.js +25 -3
  20. package/dist/dashboard/pages/agents.js +30 -1
  21. package/dist/dashboard/pages/cluster.js +512 -0
  22. package/dist/index.js +4 -4
  23. package/dist/routes-IGR6PZCA.js +92 -0
  24. package/dist/routes-XYR2RNEC.js +92 -0
  25. package/dist/runtime-EAWOE6JZ.js +45 -0
  26. package/dist/runtime-ZOC337DD.js +45 -0
  27. package/dist/server-7NT4LMSQ.js +28 -0
  28. package/dist/server-B3VJ6MSA.js +28 -0
  29. package/dist/setup-5YRQUOW2.js +20 -0
  30. package/dist/setup-6NUSB4XO.js +20 -0
  31. package/logs/cloudflared-error.log +8 -0
  32. package/logs/enterprise-out.log +3 -0
  33. package/package.json +1 -1
  34. package/src/cli-agent.ts +33 -1
  35. package/src/dashboard/app.js +4 -1
  36. package/src/dashboard/components/icons.js +1 -0
  37. package/src/dashboard/docs/cluster.html +285 -0
  38. package/src/dashboard/pages/agent-detail/index.js +25 -3
  39. package/src/dashboard/pages/agents.js +30 -1
  40. package/src/dashboard/pages/cluster.js +512 -0
  41. package/src/engine/cluster.ts +278 -0
  42. package/src/engine/routes.ts +163 -1
  43. package/src/engine/NOTE.MD +0 -52
@@ -0,0 +1,285 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>Cluster Management — AgenticMail Enterprise Docs</title>
6
+ <link rel="stylesheet" href="docs.css">
7
+ </head>
8
+ <body>
9
+ <div class="docs-container">
10
+ <nav class="docs-nav"><a href="/dashboard">&larr; Back to Dashboard</a></nav>
11
+
12
+ <h1>Cluster Management</h1>
13
+ <p class="docs-subtitle">Scale your AI workforce across multiple machines — Mac Minis, VPS, cloud instances, or any combination.</p>
14
+
15
+ <div class="docs-toc">
16
+ <h4>Contents</h4>
17
+ <ul>
18
+ <li><a href="#overview">Overview</a></li>
19
+ <li><a href="#architecture">Architecture</a></li>
20
+ <li><a href="#adding-nodes">Adding Worker Nodes</a></li>
21
+ <li><a href="#manual">Method 1: Manual Registration</a></li>
22
+ <li><a href="#ssh">Method 2: SSH Deploy</a></li>
23
+ <li><a href="#script">Method 3: Setup Script</a></li>
24
+ <li><a href="#env-vars">Environment Variables</a></li>
25
+ <li><a href="#monitoring">Monitoring & Health</a></li>
26
+ <li><a href="#node-detail">Node Detail & Actions</a></li>
27
+ <li><a href="#load-balancing">Load Balancing</a></li>
28
+ <li><a href="#database">Database Sharing</a></li>
29
+ <li><a href="#networking">Networking Requirements</a></li>
30
+ <li><a href="#security">Security Considerations</a></li>
31
+ <li><a href="#edge-cases">Edge Cases & Troubleshooting</a></li>
32
+ <li><a href="#api">API Reference</a></li>
33
+ </ul>
34
+ </div>
35
+
36
+ <h2 id="overview">Overview</h2>
37
+ <p>The Cluster system enables <strong>horizontal scaling</strong> of your AI agent workforce. Instead of running all agents on a single machine, you can distribute them across multiple worker nodes — each running one or more agents that report back to a central dashboard.</p>
38
+ <p>This is useful when:</p>
39
+ <ul>
40
+ <li>You have more agents than a single machine can handle</li>
41
+ <li>You want geographic distribution (agents closer to users)</li>
42
+ <li>You need hardware isolation (GPU nodes for voice, separate machines for browser automation)</li>
43
+ <li>You want fault tolerance (agents survive if one machine goes down)</li>
44
+ <li>You're scaling from a single Mac Mini to a fleet of machines</li>
45
+ </ul>
46
+
47
+ <h2 id="architecture">Architecture</h2>
48
+ <div class="docs-diagram">
49
+ <pre>
50
+ ┌─────────────────────────────────────┐
51
+ │ Control Plane │
52
+ │ (Enterprise Dashboard Server) │
53
+ │ │
54
+ │ ┌──────────┐ ┌────────────────┐ │
55
+ │ │ Dashboard │ │ Cluster API │ │
56
+ │ │ (UI) │ │ (REST + SSE) │ │
57
+ │ └──────────┘ └────────────────┘ │
58
+ │ │ │ │
59
+ │ ┌──────────────────────────┐ │
60
+ │ │ Shared Database │ │
61
+ │ │ (Postgres / Supabase) │ │
62
+ │ └──────────────────────────┘ │
63
+ └─────────────┬───────────────────────┘
64
+ │ HTTP (heartbeat, status)
65
+ ┌────────┼────────┐
66
+ │ │ │
67
+ ┌────┴───┐ ┌──┴───┐ ┌──┴───┐
68
+ │Worker 1│ │Worker│ │Worker│
69
+ │Mac Mini│ │ VPS │ │ AWS │
70
+ │Agent A │ │AgentB│ │AgentC│
71
+ │Agent D │ │AgentE│ │AgentF│
72
+ └────────┘ └──────┘ └──────┘
73
+ </pre>
74
+ </div>
75
+
76
+ <h3>Key Concepts</h3>
77
+ <table>
78
+ <tr><th>Term</th><th>Description</th></tr>
79
+ <tr><td><strong>Control Plane</strong></td><td>The central enterprise server running the dashboard, API, and database. One per deployment.</td></tr>
80
+ <tr><td><strong>Worker Node</strong></td><td>Any machine running one or more agent processes. Reports to the control plane via HTTP.</td></tr>
81
+ <tr><td><strong>Node ID</strong></td><td>Unique identifier for each worker node (e.g., "mac-mini-office", "aws-us-east-1").</td></tr>
82
+ <tr><td><strong>Heartbeat</strong></td><td>Periodic HTTP POST from worker to control plane (every 30 seconds). Proves the node is alive.</td></tr>
83
+ <tr><td><strong>Stale Threshold</strong></td><td>If no heartbeat received for 90 seconds, node is marked offline.</td></tr>
84
+ <tr><td><strong>Capabilities</strong></td><td>Tags describing what the node can do: "browser", "voice", "gpu", "docker".</td></tr>
85
+ </table>
86
+
87
+ <h2 id="adding-nodes">Adding Worker Nodes</h2>
88
+ <p>There are <strong>3 ways</strong> to add a worker node, all from the dashboard UI:</p>
89
+
90
+ <h3 id="manual">Method 1: Manual Registration</h3>
91
+ <p>Best for: Machines that already have AgenticMail installed and running.</p>
92
+ <ol>
93
+ <li>Go to <strong>Operations &gt; Cluster</strong> in the sidebar</li>
94
+ <li>Click <strong>Add Worker Node</strong></li>
95
+ <li>Select the <strong>Manual Registration</strong> tab</li>
96
+ <li>Enter the node name, host IP/hostname, and port</li>
97
+ <li>Click <strong>Test Connection</strong> to verify reachability</li>
98
+ <li>Click <strong>Add Node</strong></li>
99
+ </ol>
100
+ <p>The node will appear in the cluster and start receiving heartbeats when the agent process has <code>WORKER_NODE_ID</code> set.</p>
101
+
102
+ <h3 id="ssh">Method 2: SSH Deploy</h3>
103
+ <p>Best for: Fresh machines where you want the dashboard to handle everything.</p>
104
+ <ol>
105
+ <li>Click <strong>Add Worker Node</strong> &gt; <strong>Deploy via SSH</strong> tab</li>
106
+ <li>Enter the SSH host, username, and optionally paste a private key</li>
107
+ <li>Optionally specify which agent IDs to deploy</li>
108
+ <li>Click <strong>Deploy Worker</strong></li>
109
+ </ol>
110
+ <p>The dashboard will SSH into the machine, install Node.js, PM2, and AgenticMail, write the environment file, and start the agent processes. The node auto-registers on startup.</p>
111
+
112
+ <div class="docs-note">
113
+ <strong>Note:</strong> SSH deploy requires the dashboard server to have network access to the target machine on port 22. For cloud instances, make sure the security group allows SSH from the dashboard's IP.
114
+ </div>
115
+
116
+ <h3 id="script">Method 3: Setup Script</h3>
117
+ <p>Best for: Machines you can't SSH into from the dashboard (firewalled, air-gapped, or you prefer manual control).</p>
118
+ <ol>
119
+ <li>Click <strong>Add Worker Node</strong> &gt; <strong>Setup Script</strong> tab</li>
120
+ <li>Enter a name and port</li>
121
+ <li>Click <strong>Generate Setup Script</strong></li>
122
+ <li>Copy the script</li>
123
+ <li>SSH into the target machine yourself and paste/run the script</li>
124
+ <li>Edit <code>~/.agenticmail/worker.env</code> to set your <code>DATABASE_URL</code></li>
125
+ <li>Start agents with <code>pm2 start "agenticmail-enterprise agent --id &lt;ID&gt;"</code></li>
126
+ </ol>
127
+
128
+ <h2 id="env-vars">Environment Variables</h2>
129
+ <p>These environment variables control worker node behavior:</p>
130
+ <table>
131
+ <tr><th>Variable</th><th>Required</th><th>Description</th></tr>
132
+ <tr><td><code>ENTERPRISE_URL</code></td><td>Yes</td><td>Full URL of the control plane (e.g., <code>https://acme.agenticmail.io</code>)</td></tr>
133
+ <tr><td><code>WORKER_NODE_ID</code></td><td>Yes*</td><td>Unique node identifier. Triggers auto-registration on startup. <em>*Required for cluster mode.</em></td></tr>
134
+ <tr><td><code>WORKER_NAME</code></td><td>No</td><td>Human-readable name shown in dashboard. Defaults to system hostname.</td></tr>
135
+ <tr><td><code>WORKER_HOST</code></td><td>No</td><td>IP/hostname the control plane should use to reach this node. Defaults to "localhost".</td></tr>
136
+ <tr><td><code>WORKER_CAPABILITIES</code></td><td>No</td><td>Comma-separated capabilities: "browser,voice,gpu,docker"</td></tr>
137
+ <tr><td><code>DATABASE_URL</code></td><td>Yes</td><td>Same database as the control plane (shared Postgres)</td></tr>
138
+ <tr><td><code>PORT</code></td><td>No</td><td>Agent API port (default: 3101)</td></tr>
139
+ <tr><td><code>LOG_LEVEL</code></td><td>No</td><td>Set to "warn" for production noise suppression</td></tr>
140
+ </table>
141
+
142
+ <h2 id="monitoring">Monitoring & Health</h2>
143
+ <h3>Real-Time Status</h3>
144
+ <p>The Cluster page shows live status for every node via Server-Sent Events (SSE). No polling — updates appear instantly when:</p>
145
+ <ul>
146
+ <li>A node registers or re-registers</li>
147
+ <li>A heartbeat is received (every 30s)</li>
148
+ <li>A node goes offline (no heartbeat for 90s)</li>
149
+ <li>Node agent list changes</li>
150
+ </ul>
151
+
152
+ <h3>Node Statuses</h3>
153
+ <table>
154
+ <tr><th>Status</th><th>Color</th><th>Meaning</th></tr>
155
+ <tr><td>online</td><td style="color: #22c55e;">Green</td><td>Node is reachable and heartbeating normally</td></tr>
156
+ <tr><td>degraded</td><td style="color: #f59e0b;">Orange</td><td>Node is reachable but reporting issues</td></tr>
157
+ <tr><td>offline</td><td style="color: #6b7280;">Gray</td><td>No heartbeat for 90+ seconds</td></tr>
158
+ </table>
159
+
160
+ <h3>Stats Cards</h3>
161
+ <p>The top of the Cluster page shows aggregate stats:</p>
162
+ <ul>
163
+ <li><strong>Total Nodes</strong> — All registered nodes (online + offline)</li>
164
+ <li><strong>Online</strong> — Currently heartbeating nodes</li>
165
+ <li><strong>Running Agents</strong> — Total agents across all online nodes</li>
166
+ <li><strong>Total CPUs</strong> — Aggregate CPU cores across online nodes</li>
167
+ <li><strong>Total Memory</strong> — Aggregate RAM across online nodes</li>
168
+ </ul>
169
+
170
+ <h2 id="node-detail">Node Detail & Actions</h2>
171
+ <p>Click any node card to see full details:</p>
172
+ <ul>
173
+ <li><strong>Platform info</strong> — OS, architecture, CPU count, memory</li>
174
+ <li><strong>Agent list</strong> — All agents running on this node with names and roles</li>
175
+ <li><strong>Capabilities</strong> — What the node supports (browser, voice, etc.)</li>
176
+ <li><strong>Ping</strong> — Test connection from dashboard to node (shows latency)</li>
177
+ <li><strong>Restart Agents</strong> — Send restart signal to all agents on this node</li>
178
+ </ul>
179
+
180
+ <h2 id="load-balancing">Load Balancing</h2>
181
+ <p>When deploying a new agent, the system can automatically select the best node:</p>
182
+ <ul>
183
+ <li><strong>Least-loaded</strong> — Node with fewest running agents</li>
184
+ <li><strong>Capability-matching</strong> — If the agent needs "voice" or "browser", only nodes with those capabilities are considered</li>
185
+ <li><strong>API endpoint</strong>: <code>GET /api/engine/cluster/best-node?capabilities=voice,browser</code></li>
186
+ </ul>
187
+
188
+ <h2 id="database">Database Sharing</h2>
189
+ <p>All worker nodes <strong>must connect to the same database</strong> as the control plane. This is how agents share state, memory, tasks, and configuration.</p>
190
+ <div class="docs-note">
191
+ <strong>Recommended:</strong> Use a cloud-hosted PostgreSQL (Supabase, Neon, AWS RDS) accessible from all nodes. SQLite does NOT work for multi-node clusters.
192
+ </div>
193
+ <p>Connection pool settings are auto-optimized per node via the <code>smartDbConfig()</code> helper. Each node maintains its own small connection pool (3 connections max).</p>
194
+
195
+ <h2 id="networking">Networking Requirements</h2>
196
+ <table>
197
+ <tr><th>Direction</th><th>From</th><th>To</th><th>Port</th><th>Purpose</th></tr>
198
+ <tr><td>Outbound</td><td>Worker Node</td><td>Control Plane</td><td>3100 (or custom)</td><td>Heartbeats, status updates, task webhooks</td></tr>
199
+ <tr><td>Outbound</td><td>Worker Node</td><td>Database</td><td>5432 (Postgres)</td><td>Shared database connection</td></tr>
200
+ <tr><td>Inbound</td><td>Control Plane</td><td>Worker Node</td><td>3101 (or custom)</td><td>Health checks, ping, restart commands</td></tr>
201
+ <tr><td>Outbound</td><td>Control Plane</td><td>Worker Node</td><td>22 (SSH)</td><td>Only for SSH deploy method</td></tr>
202
+ </table>
203
+ <p>If nodes are behind NAT or firewalls, only outbound from worker to control plane is strictly required. The test-connection and restart features need inbound access.</p>
204
+
205
+ <h2 id="security">Security Considerations</h2>
206
+ <ul>
207
+ <li><strong>No authentication on cluster API (yet)</strong> — The heartbeat and status endpoints are unauthenticated for simplicity. Only expose the control plane's API behind a reverse proxy with authentication, or restrict by IP.</li>
208
+ <li><strong>SSH keys</strong> — For SSH deploy, keys are used once and not persisted. Prefer SSH agent forwarding or temporary keys.</li>
209
+ <li><strong>Database credentials</strong> — Each worker node needs <code>DATABASE_URL</code>. Use environment variables, never commit credentials.</li>
210
+ <li><strong>TLS</strong> — Use HTTPS between workers and control plane in production. Set <code>ENTERPRISE_URL=https://...</code>.</li>
211
+ <li><strong>Network segmentation</strong> — Place worker nodes and control plane on the same VPN/VPC for internal traffic.</li>
212
+ </ul>
213
+
214
+ <h2 id="edge-cases">Edge Cases & Troubleshooting</h2>
215
+
216
+ <h3>Node keeps showing "offline"</h3>
217
+ <ul>
218
+ <li>Check <code>ENTERPRISE_URL</code> is correct and reachable from the worker</li>
219
+ <li>Check <code>WORKER_NODE_ID</code> is set in the agent's environment</li>
220
+ <li>Check firewall rules — worker must be able to POST to <code>ENTERPRISE_URL/api/engine/cluster/heartbeat/...</code></li>
221
+ <li>Check agent logs: <code>pm2 logs agent-name</code></li>
222
+ </ul>
223
+
224
+ <h3>Duplicate node IDs</h3>
225
+ <p>If two machines use the same <code>WORKER_NODE_ID</code>, they'll overwrite each other's registration. Use unique IDs per machine.</p>
226
+
227
+ <h3>Agent appears on wrong node</h3>
228
+ <p>Each agent process reports its <code>WORKER_NODE_ID</code> on startup. If you move an agent between machines, restart it on the new machine — it will re-register under the new node.</p>
229
+
230
+ <h3>Control plane restarts</h3>
231
+ <p>All node data is persisted in the <code>cluster_nodes</code> database table. On restart, nodes load from DB as "offline" and transition to "online" when the next heartbeat arrives (within 30s).</p>
232
+
233
+ <h3>Worker restarts</h3>
234
+ <p>PM2 auto-restarts crashed agent processes. On restart, the agent re-registers with the control plane within seconds.</p>
235
+
236
+ <h3>Network partition</h3>
237
+ <p>If a worker loses connectivity to the control plane, it continues running agents normally. It just stops reporting status. When connectivity resumes, the next heartbeat restores the "online" status.</p>
238
+
239
+ <h3>Database failover</h3>
240
+ <p>All nodes connect to the same database. If the database goes down, all nodes are affected. Use a cloud provider with automatic failover (Supabase, Neon, RDS Multi-AZ).</p>
241
+
242
+ <h2 id="api">API Reference</h2>
243
+ <table>
244
+ <tr><th>Method</th><th>Endpoint</th><th>Description</th></tr>
245
+ <tr><td>GET</td><td><code>/api/engine/cluster/nodes</code></td><td>List all nodes + cluster stats</td></tr>
246
+ <tr><td>GET</td><td><code>/api/engine/cluster/nodes/:nodeId</code></td><td>Get specific node</td></tr>
247
+ <tr><td>POST</td><td><code>/api/engine/cluster/register</code></td><td>Register a worker node</td></tr>
248
+ <tr><td>POST</td><td><code>/api/engine/cluster/heartbeat/:nodeId</code></td><td>Worker heartbeat</td></tr>
249
+ <tr><td>DELETE</td><td><code>/api/engine/cluster/nodes/:nodeId</code></td><td>Remove a node</td></tr>
250
+ <tr><td>GET</td><td><code>/api/engine/cluster/best-node</code></td><td>Find best node for deployment</td></tr>
251
+ <tr><td>POST</td><td><code>/api/engine/cluster/test-connection</code></td><td>Test connectivity to a node</td></tr>
252
+ <tr><td>POST</td><td><code>/api/engine/cluster/deploy-via-ssh</code></td><td>Deploy worker via SSH</td></tr>
253
+ <tr><td>POST</td><td><code>/api/engine/cluster/nodes/:nodeId/restart</code></td><td>Restart agents on a node</td></tr>
254
+ <tr><td>GET</td><td><code>/api/engine/cluster/stream</code></td><td>SSE stream of cluster events</td></tr>
255
+ </table>
256
+
257
+ <h3>Register Node (POST /api/engine/cluster/register)</h3>
258
+ <pre>
259
+ {
260
+ "nodeId": "mac-mini-office", // Required, unique, 2-64 chars, alphanumeric + .-_
261
+ "name": "Office Mac Mini", // Optional display name
262
+ "host": "192.168.1.50", // Required, IP or hostname
263
+ "port": 3101, // Required, 1-65535
264
+ "platform": "darwin", // Optional, auto-detected
265
+ "arch": "arm64", // Optional, auto-detected
266
+ "cpuCount": 10, // Optional, auto-detected
267
+ "memoryMb": 16384, // Optional, auto-detected
268
+ "version": "0.5.324", // Optional
269
+ "agents": ["agent-uuid-1"], // Optional, list of agent IDs
270
+ "capabilities": ["browser", "voice"] // Optional
271
+ }
272
+ </pre>
273
+
274
+ <h3>Heartbeat (POST /api/engine/cluster/heartbeat/:nodeId)</h3>
275
+ <pre>
276
+ {
277
+ "agents": ["agent-uuid-1"], // Current agent list
278
+ "cpuUsage": 0.45, // Optional, 0-1
279
+ "memoryUsage": 0.62 // Optional, 0-1
280
+ }
281
+ </pre>
282
+
283
+ </div>
284
+ </body>
285
+ </html>
@@ -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
- var state = ea.state || ea.status || a.status || 'unknown';
113
- var stateColor = { running: 'success', active: 'success', deploying: 'info', starting: 'info', provisioning: 'info', degraded: 'warning', error: 'danger', stopped: 'neutral', draft: 'neutral', ready: 'primary' }[state] || 'neutral';
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, h('span', { className: 'badge badge-' + (a.status === 'active' ? 'success' : a.status === 'archived' ? 'neutral' : 'warning') }, a.status || 'active')),
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 } },