@agent-relay/resiliency 0.1.0
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/context-persistence.d.ts +140 -0
- package/dist/context-persistence.d.ts.map +1 -0
- package/dist/context-persistence.js +397 -0
- package/dist/context-persistence.js.map +1 -0
- package/dist/crash-insights.d.ts +156 -0
- package/dist/crash-insights.d.ts.map +1 -0
- package/dist/crash-insights.js +492 -0
- package/dist/crash-insights.js.map +1 -0
- package/dist/gossip-health.d.ts +137 -0
- package/dist/gossip-health.d.ts.map +1 -0
- package/dist/gossip-health.js +241 -0
- package/dist/gossip-health.js.map +1 -0
- package/dist/health-monitor.d.ts +97 -0
- package/dist/health-monitor.d.ts.map +1 -0
- package/dist/health-monitor.js +291 -0
- package/dist/health-monitor.js.map +1 -0
- package/dist/index.d.ts +68 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +68 -0
- package/dist/index.js.map +1 -0
- package/dist/leader-watchdog.d.ts +109 -0
- package/dist/leader-watchdog.d.ts.map +1 -0
- package/dist/leader-watchdog.js +189 -0
- package/dist/leader-watchdog.js.map +1 -0
- package/dist/logger.d.ts +114 -0
- package/dist/logger.d.ts.map +1 -0
- package/dist/logger.js +250 -0
- package/dist/logger.js.map +1 -0
- package/dist/memory-monitor.d.ts +172 -0
- package/dist/memory-monitor.d.ts.map +1 -0
- package/dist/memory-monitor.js +599 -0
- package/dist/memory-monitor.js.map +1 -0
- package/dist/metrics.d.ts +115 -0
- package/dist/metrics.d.ts.map +1 -0
- package/dist/metrics.js +239 -0
- package/dist/metrics.js.map +1 -0
- package/dist/provider-context.d.ts +100 -0
- package/dist/provider-context.d.ts.map +1 -0
- package/dist/provider-context.js +362 -0
- package/dist/provider-context.js.map +1 -0
- package/dist/stateless-lead.d.ts +149 -0
- package/dist/stateless-lead.d.ts.map +1 -0
- package/dist/stateless-lead.js +308 -0
- package/dist/stateless-lead.js.map +1 -0
- package/dist/supervisor.d.ts +147 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +459 -0
- package/dist/supervisor.js.map +1 -0
- package/package.json +28 -0
|
@@ -0,0 +1,459 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Agent Supervisor
|
|
3
|
+
*
|
|
4
|
+
* High-level supervisor that combines health monitoring, logging, and metrics
|
|
5
|
+
* to provide comprehensive agent resiliency.
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from 'events';
|
|
8
|
+
import { getHealthMonitor } from './health-monitor.js';
|
|
9
|
+
import { createLogger } from './logger.js';
|
|
10
|
+
import { metrics } from './metrics.js';
|
|
11
|
+
import { getContextPersistence } from './context-persistence.js';
|
|
12
|
+
import { createContextHandler, detectProvider } from './provider-context.js';
|
|
13
|
+
import { LeaderWatchdog } from './leader-watchdog.js';
|
|
14
|
+
import { StatelessLeadCoordinator } from './stateless-lead.js';
|
|
15
|
+
const DEFAULT_CONFIG = {
|
|
16
|
+
healthCheck: {
|
|
17
|
+
checkIntervalMs: 5000,
|
|
18
|
+
maxRestarts: 5,
|
|
19
|
+
},
|
|
20
|
+
logging: {
|
|
21
|
+
level: 'info',
|
|
22
|
+
},
|
|
23
|
+
autoRestart: true,
|
|
24
|
+
maxRestarts: 5,
|
|
25
|
+
notifyOnCrash: true,
|
|
26
|
+
contextPersistence: {
|
|
27
|
+
enabled: true,
|
|
28
|
+
autoInjectOnRestart: true,
|
|
29
|
+
},
|
|
30
|
+
};
|
|
31
|
+
export class AgentSupervisor extends EventEmitter {
|
|
32
|
+
config;
|
|
33
|
+
healthMonitor;
|
|
34
|
+
logger;
|
|
35
|
+
agents = new Map();
|
|
36
|
+
restarters = new Map();
|
|
37
|
+
contextPersistence;
|
|
38
|
+
contextHandlers = new Map();
|
|
39
|
+
leaderWatchdog;
|
|
40
|
+
leadCoordinator;
|
|
41
|
+
supervisorAgentId;
|
|
42
|
+
constructor(config = {}) {
|
|
43
|
+
super();
|
|
44
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
45
|
+
this.supervisorAgentId = `supervisor-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
46
|
+
this.logger = createLogger('supervisor', {
|
|
47
|
+
level: this.config.logging.level,
|
|
48
|
+
file: this.config.logging.file,
|
|
49
|
+
});
|
|
50
|
+
this.healthMonitor = getHealthMonitor(this.config.healthCheck);
|
|
51
|
+
this.setupHealthMonitorEvents();
|
|
52
|
+
// Initialize context persistence if enabled
|
|
53
|
+
if (this.config.contextPersistence.enabled) {
|
|
54
|
+
this.contextPersistence = getContextPersistence(this.config.contextPersistence.baseDir);
|
|
55
|
+
this.contextPersistence.startAutoSave();
|
|
56
|
+
this.logger.info('Context persistence enabled');
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Start supervising agents
|
|
61
|
+
*/
|
|
62
|
+
start() {
|
|
63
|
+
this.logger.info('Agent supervisor started', {
|
|
64
|
+
autoRestart: this.config.autoRestart,
|
|
65
|
+
maxRestarts: this.config.maxRestarts,
|
|
66
|
+
});
|
|
67
|
+
this.healthMonitor.start();
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Stop supervising agents
|
|
71
|
+
*/
|
|
72
|
+
stop() {
|
|
73
|
+
this.logger.info('Agent supervisor stopping');
|
|
74
|
+
this.healthMonitor.stop();
|
|
75
|
+
// Stop leader coordination
|
|
76
|
+
if (this.leaderWatchdog) {
|
|
77
|
+
this.leaderWatchdog.stop();
|
|
78
|
+
}
|
|
79
|
+
if (this.leadCoordinator) {
|
|
80
|
+
this.leadCoordinator.stop().catch((err) => {
|
|
81
|
+
this.logger.error('Error stopping lead coordinator', { error: String(err) });
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
// Stop context persistence
|
|
85
|
+
if (this.contextPersistence) {
|
|
86
|
+
this.contextPersistence.stopAutoSave();
|
|
87
|
+
}
|
|
88
|
+
// Cleanup context handlers
|
|
89
|
+
Array.from(this.contextHandlers.entries()).forEach(([name, handler]) => {
|
|
90
|
+
handler.cleanup().catch((err) => {
|
|
91
|
+
this.logger.error('Error cleaning up context handler', { name, error: String(err) });
|
|
92
|
+
});
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Enable leader coordination with watchdog
|
|
97
|
+
* This allows this supervisor to participate in leader election and
|
|
98
|
+
* potentially become the lead coordinator for task distribution.
|
|
99
|
+
*/
|
|
100
|
+
enableLeaderCoordination(beadsDir, sendRelay) {
|
|
101
|
+
if (this.leaderWatchdog) {
|
|
102
|
+
this.logger.warn('Leader coordination already enabled');
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
this.logger.info('Enabling leader coordination', { beadsDir });
|
|
106
|
+
// Create watchdog to monitor leader health
|
|
107
|
+
this.leaderWatchdog = new LeaderWatchdog({
|
|
108
|
+
beadsDir,
|
|
109
|
+
agentName: 'supervisor',
|
|
110
|
+
agentId: this.supervisorAgentId,
|
|
111
|
+
checkIntervalMs: 5000,
|
|
112
|
+
staleThresholdMs: 30000,
|
|
113
|
+
onBecomeLeader: async () => {
|
|
114
|
+
await this.becomeLeader(beadsDir, sendRelay);
|
|
115
|
+
},
|
|
116
|
+
getHealthyAgents: async () => {
|
|
117
|
+
return this.getHealthyAgents();
|
|
118
|
+
},
|
|
119
|
+
});
|
|
120
|
+
// Forward watchdog events
|
|
121
|
+
this.leaderWatchdog.on('electionStarted', (data) => this.emit('electionStarted', data));
|
|
122
|
+
this.leaderWatchdog.on('electionComplete', (data) => this.emit('electionComplete', data));
|
|
123
|
+
this.leaderWatchdog.on('becameLeader', () => this.emit('becameLeader'));
|
|
124
|
+
this.leaderWatchdog.on('leaderStale', (data) => this.emit('leaderStale', data));
|
|
125
|
+
this.leaderWatchdog.start();
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Called when this supervisor wins leader election
|
|
129
|
+
*/
|
|
130
|
+
async becomeLeader(beadsDir, sendRelay) {
|
|
131
|
+
this.logger.info('This supervisor is becoming the lead coordinator');
|
|
132
|
+
// Stop existing coordinator if any
|
|
133
|
+
if (this.leadCoordinator) {
|
|
134
|
+
await this.leadCoordinator.stop();
|
|
135
|
+
}
|
|
136
|
+
// Create stateless lead coordinator
|
|
137
|
+
this.leadCoordinator = new StatelessLeadCoordinator({
|
|
138
|
+
beadsDir,
|
|
139
|
+
agentName: 'supervisor',
|
|
140
|
+
agentId: this.supervisorAgentId,
|
|
141
|
+
pollIntervalMs: 5000,
|
|
142
|
+
heartbeatIntervalMs: 10000,
|
|
143
|
+
leaseDurationMs: 300000,
|
|
144
|
+
sendRelay,
|
|
145
|
+
getAvailableWorkers: async () => {
|
|
146
|
+
return this.getAvailableWorkerNames();
|
|
147
|
+
},
|
|
148
|
+
});
|
|
149
|
+
// Forward coordinator events
|
|
150
|
+
this.leadCoordinator.on('assigned', (data) => this.emit('taskAssigned', data));
|
|
151
|
+
this.leadCoordinator.on('completed', (data) => this.emit('taskCompleted', data));
|
|
152
|
+
await this.leadCoordinator.start();
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Get healthy agents for leader election
|
|
156
|
+
*/
|
|
157
|
+
getHealthyAgents() {
|
|
158
|
+
const healthyAgents = [];
|
|
159
|
+
for (const [name, agent] of this.agents) {
|
|
160
|
+
const health = this.healthMonitor.get(name);
|
|
161
|
+
if (health && health.status === 'healthy') {
|
|
162
|
+
healthyAgents.push({
|
|
163
|
+
name: agent.name,
|
|
164
|
+
id: `${agent.name}-${agent.pid}`,
|
|
165
|
+
spawnedAt: agent.spawnedAt,
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
// Include supervisor itself as a candidate
|
|
170
|
+
healthyAgents.push({
|
|
171
|
+
name: 'supervisor',
|
|
172
|
+
id: this.supervisorAgentId,
|
|
173
|
+
spawnedAt: new Date(0), // Supervisor is always oldest
|
|
174
|
+
});
|
|
175
|
+
return healthyAgents;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Get available worker names (healthy agents not currently busy)
|
|
179
|
+
*/
|
|
180
|
+
getAvailableWorkerNames() {
|
|
181
|
+
const available = [];
|
|
182
|
+
for (const [name, agent] of this.agents) {
|
|
183
|
+
const health = this.healthMonitor.get(name);
|
|
184
|
+
if (health && health.status === 'healthy') {
|
|
185
|
+
available.push(agent.name);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
return available;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Check if this supervisor is currently the leader
|
|
192
|
+
*/
|
|
193
|
+
isLeader() {
|
|
194
|
+
return this.leaderWatchdog?.isCurrentLeader() ?? false;
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Get current leader info
|
|
198
|
+
*/
|
|
199
|
+
getCurrentLeader() {
|
|
200
|
+
return this.leaderWatchdog?.getCurrentLeader() ?? null;
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Add an agent to supervision
|
|
204
|
+
*/
|
|
205
|
+
supervise(agent, options) {
|
|
206
|
+
this.agents.set(agent.name, agent);
|
|
207
|
+
this.restarters.set(agent.name, options.restart);
|
|
208
|
+
// Create agent process wrapper for health monitor
|
|
209
|
+
const agentProcess = {
|
|
210
|
+
name: agent.name,
|
|
211
|
+
pid: agent.pid,
|
|
212
|
+
isAlive: options.isAlive,
|
|
213
|
+
kill: options.kill,
|
|
214
|
+
restart: async () => {
|
|
215
|
+
if (this.config.autoRestart) {
|
|
216
|
+
await options.restart();
|
|
217
|
+
// Update PID after restart
|
|
218
|
+
const updated = this.agents.get(agent.name);
|
|
219
|
+
if (updated) {
|
|
220
|
+
agentProcess.pid = updated.pid;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
},
|
|
224
|
+
sendHealthCheck: options.sendHealthCheck,
|
|
225
|
+
};
|
|
226
|
+
this.healthMonitor.register(agentProcess);
|
|
227
|
+
metrics.recordSpawn(agent.name);
|
|
228
|
+
// Set up context persistence for this agent
|
|
229
|
+
if (this.contextPersistence && this.config.contextPersistence.enabled) {
|
|
230
|
+
const provider = agent.provider || detectProvider(agent.cli);
|
|
231
|
+
const workingDir = agent.workingDir || process.cwd();
|
|
232
|
+
// Initialize agent state
|
|
233
|
+
this.contextPersistence.initAgent(agent.name, agent.cli, agent.task);
|
|
234
|
+
// Create provider-specific context handler
|
|
235
|
+
const contextHandler = createContextHandler({
|
|
236
|
+
provider,
|
|
237
|
+
workingDir,
|
|
238
|
+
agentName: agent.name,
|
|
239
|
+
task: agent.task,
|
|
240
|
+
});
|
|
241
|
+
contextHandler.setup().then(() => {
|
|
242
|
+
this.contextHandlers.set(agent.name, contextHandler);
|
|
243
|
+
// Check for existing handoff to restore
|
|
244
|
+
const handoff = this.contextPersistence?.loadHandoff(agent.name);
|
|
245
|
+
if (handoff && this.config.contextPersistence.autoInjectOnRestart) {
|
|
246
|
+
contextHandler.injectContext(handoff).catch((err) => {
|
|
247
|
+
this.logger.error('Failed to inject context on start', {
|
|
248
|
+
name: agent.name,
|
|
249
|
+
error: String(err),
|
|
250
|
+
});
|
|
251
|
+
});
|
|
252
|
+
}
|
|
253
|
+
}).catch((err) => {
|
|
254
|
+
this.logger.error('Failed to setup context handler', {
|
|
255
|
+
name: agent.name,
|
|
256
|
+
provider,
|
|
257
|
+
error: String(err),
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
}
|
|
261
|
+
this.logger.info('Agent added to supervision', {
|
|
262
|
+
name: agent.name,
|
|
263
|
+
cli: agent.cli,
|
|
264
|
+
pid: agent.pid,
|
|
265
|
+
});
|
|
266
|
+
}
|
|
267
|
+
/**
|
|
268
|
+
* Remove an agent from supervision
|
|
269
|
+
*/
|
|
270
|
+
unsupervise(name) {
|
|
271
|
+
this.agents.delete(name);
|
|
272
|
+
this.restarters.delete(name);
|
|
273
|
+
this.healthMonitor.unregister(name);
|
|
274
|
+
// Clean up context handler
|
|
275
|
+
const contextHandler = this.contextHandlers.get(name);
|
|
276
|
+
if (contextHandler) {
|
|
277
|
+
contextHandler.saveContext().then(() => {
|
|
278
|
+
return contextHandler.cleanup();
|
|
279
|
+
}).catch((err) => {
|
|
280
|
+
this.logger.error('Error cleaning up context handler', { name, error: String(err) });
|
|
281
|
+
});
|
|
282
|
+
this.contextHandlers.delete(name);
|
|
283
|
+
}
|
|
284
|
+
this.logger.info('Agent removed from supervision', { name });
|
|
285
|
+
}
|
|
286
|
+
/**
|
|
287
|
+
* Update agent info (e.g., after restart)
|
|
288
|
+
*/
|
|
289
|
+
updateAgent(name, updates) {
|
|
290
|
+
const agent = this.agents.get(name);
|
|
291
|
+
if (agent) {
|
|
292
|
+
Object.assign(agent, updates);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* Get all supervised agents
|
|
297
|
+
*/
|
|
298
|
+
getAgents() {
|
|
299
|
+
return Array.from(this.agents.values());
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* Get agent status
|
|
303
|
+
*/
|
|
304
|
+
getStatus(name) {
|
|
305
|
+
return {
|
|
306
|
+
agent: this.agents.get(name),
|
|
307
|
+
health: this.healthMonitor.get(name),
|
|
308
|
+
metrics: metrics.getAgentMetrics(name),
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
/**
|
|
312
|
+
* Get overall supervisor status
|
|
313
|
+
*/
|
|
314
|
+
getOverallStatus() {
|
|
315
|
+
return {
|
|
316
|
+
agents: this.getAgents(),
|
|
317
|
+
health: this.healthMonitor.getAll(),
|
|
318
|
+
systemMetrics: metrics.getSystemMetrics(),
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
/**
|
|
322
|
+
* Force restart an agent
|
|
323
|
+
*/
|
|
324
|
+
async forceRestart(name) {
|
|
325
|
+
const restarter = this.restarters.get(name);
|
|
326
|
+
if (!restarter) {
|
|
327
|
+
throw new Error(`Agent ${name} not found`);
|
|
328
|
+
}
|
|
329
|
+
this.logger.info('Force restarting agent', { name });
|
|
330
|
+
metrics.recordRestartAttempt(name);
|
|
331
|
+
try {
|
|
332
|
+
await restarter();
|
|
333
|
+
metrics.recordRestartSuccess(name);
|
|
334
|
+
this.logger.info('Force restart successful', { name });
|
|
335
|
+
}
|
|
336
|
+
catch (error) {
|
|
337
|
+
const reason = error instanceof Error ? error.message : String(error);
|
|
338
|
+
metrics.recordRestartFailure(name, reason);
|
|
339
|
+
this.logger.error('Force restart failed', { name, error: reason });
|
|
340
|
+
throw error;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
/**
|
|
344
|
+
* Setup event handlers for health monitor
|
|
345
|
+
*/
|
|
346
|
+
setupHealthMonitorEvents() {
|
|
347
|
+
this.healthMonitor.on('healthy', ({ name, health }) => {
|
|
348
|
+
this.emit('healthy', { name, health });
|
|
349
|
+
});
|
|
350
|
+
this.healthMonitor.on('unhealthy', ({ name, health }) => {
|
|
351
|
+
this.logger.warn('Agent unhealthy', {
|
|
352
|
+
name,
|
|
353
|
+
consecutiveFailures: health.consecutiveFailures,
|
|
354
|
+
});
|
|
355
|
+
this.emit('unhealthy', { name, health });
|
|
356
|
+
});
|
|
357
|
+
this.healthMonitor.on('died', ({ name, reason, restartCount }) => {
|
|
358
|
+
this.logger.error('Agent died', { name, reason, restartCount });
|
|
359
|
+
metrics.recordCrash(name, reason);
|
|
360
|
+
this.emit('died', { name, reason, restartCount });
|
|
361
|
+
// Record crash in context persistence for resumption
|
|
362
|
+
if (this.contextPersistence) {
|
|
363
|
+
this.contextPersistence.recordCrash(name, reason);
|
|
364
|
+
}
|
|
365
|
+
if (this.config.notifyOnCrash) {
|
|
366
|
+
this.notifyCrash(name, reason);
|
|
367
|
+
}
|
|
368
|
+
});
|
|
369
|
+
this.healthMonitor.on('restarting', ({ name, attempt }) => {
|
|
370
|
+
this.logger.info('Restarting agent', { name, attempt });
|
|
371
|
+
metrics.recordRestartAttempt(name);
|
|
372
|
+
// Save checkpoint before restart
|
|
373
|
+
if (this.contextPersistence) {
|
|
374
|
+
this.contextPersistence.checkpoint(name);
|
|
375
|
+
}
|
|
376
|
+
this.emit('restarting', { name, attempt });
|
|
377
|
+
});
|
|
378
|
+
this.healthMonitor.on('restarted', ({ name, pid, attempt }) => {
|
|
379
|
+
this.logger.info('Agent restarted', { name, pid, attempt });
|
|
380
|
+
metrics.recordRestartSuccess(name);
|
|
381
|
+
// Update our agent record
|
|
382
|
+
const agent = this.agents.get(name);
|
|
383
|
+
if (agent) {
|
|
384
|
+
agent.pid = pid;
|
|
385
|
+
agent.spawnedAt = new Date();
|
|
386
|
+
}
|
|
387
|
+
// Inject context on restart
|
|
388
|
+
if (this.config.contextPersistence.autoInjectOnRestart) {
|
|
389
|
+
const handoff = this.contextPersistence?.loadHandoff(name);
|
|
390
|
+
const contextHandler = this.contextHandlers.get(name);
|
|
391
|
+
if (handoff && contextHandler) {
|
|
392
|
+
contextHandler.injectContext(handoff).catch((err) => {
|
|
393
|
+
this.logger.error('Failed to inject context after restart', {
|
|
394
|
+
name,
|
|
395
|
+
error: String(err),
|
|
396
|
+
});
|
|
397
|
+
});
|
|
398
|
+
}
|
|
399
|
+
}
|
|
400
|
+
this.emit('restarted', { name, pid, attempt });
|
|
401
|
+
});
|
|
402
|
+
this.healthMonitor.on('restartFailed', ({ name, error }) => {
|
|
403
|
+
this.logger.error('Restart failed', { name, error });
|
|
404
|
+
metrics.recordRestartFailure(name, error);
|
|
405
|
+
this.emit('restartFailed', { name, error });
|
|
406
|
+
});
|
|
407
|
+
this.healthMonitor.on('permanentlyDead', ({ name, health }) => {
|
|
408
|
+
this.logger.fatal('Agent permanently dead', {
|
|
409
|
+
name,
|
|
410
|
+
restartCount: health.restartCount,
|
|
411
|
+
lastError: health.lastError,
|
|
412
|
+
});
|
|
413
|
+
metrics.recordDead(name);
|
|
414
|
+
this.emit('permanentlyDead', { name, health });
|
|
415
|
+
if (this.config.notifyOnCrash) {
|
|
416
|
+
this.notifyDead(name, health.lastError);
|
|
417
|
+
}
|
|
418
|
+
});
|
|
419
|
+
this.healthMonitor.on('log', (entry) => {
|
|
420
|
+
// Forward health monitor logs
|
|
421
|
+
this.emit('log', entry);
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Send notification about agent crash
|
|
426
|
+
*/
|
|
427
|
+
notifyCrash(name, reason) {
|
|
428
|
+
// In cloud deployment, this would send to a notification service
|
|
429
|
+
// For now, just emit an event
|
|
430
|
+
this.emit('notification', {
|
|
431
|
+
type: 'crash',
|
|
432
|
+
severity: 'warning',
|
|
433
|
+
title: `Agent ${name} crashed`,
|
|
434
|
+
message: reason,
|
|
435
|
+
timestamp: new Date(),
|
|
436
|
+
});
|
|
437
|
+
}
|
|
438
|
+
/**
|
|
439
|
+
* Send notification about permanently dead agent
|
|
440
|
+
*/
|
|
441
|
+
notifyDead(name, reason) {
|
|
442
|
+
this.emit('notification', {
|
|
443
|
+
type: 'dead',
|
|
444
|
+
severity: 'critical',
|
|
445
|
+
title: `Agent ${name} is permanently dead`,
|
|
446
|
+
message: reason || 'Exceeded max restart attempts',
|
|
447
|
+
timestamp: new Date(),
|
|
448
|
+
});
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
// Singleton instance
|
|
452
|
+
let _supervisor = null;
|
|
453
|
+
export function getSupervisor(config) {
|
|
454
|
+
if (!_supervisor) {
|
|
455
|
+
_supervisor = new AgentSupervisor(config);
|
|
456
|
+
}
|
|
457
|
+
return _supervisor;
|
|
458
|
+
}
|
|
459
|
+
//# sourceMappingURL=supervisor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"supervisor.js","sourceRoot":"","sources":["../src/supervisor.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,EAAsB,gBAAgB,EAAkD,MAAM,qBAAqB,CAAC;AAC3H,OAAO,EAAU,YAAY,EAAY,MAAM,aAAa,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,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AAK,EAAE,KAAK,CAAC,CAAC;QAC1B,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,WAAW,CAAC,IAAY,EAAE,MAAc;QAC9C,iEAAiE;QACjE,8BAA8B;QAC9B,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxB,IAAI,EAAE,OAAO;YACb,QAAQ,EAAE,SAAS;YACnB,KAAK,EAAE,SAAS,IAAI,UAAU;YAC9B,OAAO,EAAE,MAAM;YACf,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACK,UAAU,CAAC,IAAY,EAAE,MAAe;QAC9C,IAAI,CAAC,IAAI,CAAC,cAAc,EAAE;YACxB,IAAI,EAAE,MAAM;YACZ,QAAQ,EAAE,UAAU;YACpB,KAAK,EAAE,SAAS,IAAI,sBAAsB;YAC1C,OAAO,EAAE,MAAM,IAAI,+BAA+B;YAClD,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAC,CAAC;IACL,CAAC;CACF;AAED,qBAAqB;AACrB,IAAI,WAAW,GAA2B,IAAI,CAAC;AAE/C,MAAM,UAAU,aAAa,CAAC,MAAkC;IAC9D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,WAAW,GAAG,IAAI,eAAe,CAAC,MAAM,CAAC,CAAC;IAC5C,CAAC;IACD,OAAO,WAAW,CAAC;AACrB,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agent-relay/resiliency",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Health monitoring, logging, metrics, and crash resilience utilities for Agent Relay",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
11
|
+
"import": "./dist/index.js"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
"files": ["dist", "README.md"],
|
|
15
|
+
"scripts": {
|
|
16
|
+
"build": "tsc",
|
|
17
|
+
"clean": "rm -rf dist",
|
|
18
|
+
"test": "vitest run",
|
|
19
|
+
"test:watch": "vitest"
|
|
20
|
+
},
|
|
21
|
+
"dependencies": {},
|
|
22
|
+
"devDependencies": {
|
|
23
|
+
"@types/node": "^22.19.3",
|
|
24
|
+
"typescript": "^5.9.3",
|
|
25
|
+
"vitest": "^3.2.4"
|
|
26
|
+
},
|
|
27
|
+
"publishConfig": { "access": "public" }
|
|
28
|
+
}
|