@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,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Leader Watchdog
|
|
3
|
+
*
|
|
4
|
+
* Implements P3: Monitor lead health, trigger promotion if lead dies.
|
|
5
|
+
* Integrates with AgentSupervisor and heartbeat system.
|
|
6
|
+
*
|
|
7
|
+
* Features:
|
|
8
|
+
* - Monitors leader heartbeat file
|
|
9
|
+
* - Detects stale/missing leader
|
|
10
|
+
* - Triggers leader election or self-promotion
|
|
11
|
+
* - Integrates with supervisor events
|
|
12
|
+
*/
|
|
13
|
+
import * as path from 'path';
|
|
14
|
+
import { EventEmitter } from 'events';
|
|
15
|
+
import { StatelessLeadCoordinator } from './stateless-lead.js';
|
|
16
|
+
const DEFAULT_CONFIG = {
|
|
17
|
+
checkIntervalMs: 5000,
|
|
18
|
+
staleThresholdMs: 30000,
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Leader Watchdog
|
|
22
|
+
*
|
|
23
|
+
* Runs on each agent, monitors leader health, triggers election if needed.
|
|
24
|
+
*/
|
|
25
|
+
export class LeaderWatchdog extends EventEmitter {
|
|
26
|
+
config;
|
|
27
|
+
heartbeatPath;
|
|
28
|
+
checkInterval;
|
|
29
|
+
isRunning = false;
|
|
30
|
+
currentLeader = null;
|
|
31
|
+
isLeader = false;
|
|
32
|
+
constructor(config) {
|
|
33
|
+
super();
|
|
34
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
35
|
+
this.heartbeatPath = path.join(this.config.beadsDir, 'leader-heartbeat.json');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Start watching for leader health
|
|
39
|
+
*/
|
|
40
|
+
start() {
|
|
41
|
+
if (this.isRunning)
|
|
42
|
+
return;
|
|
43
|
+
this.isRunning = true;
|
|
44
|
+
console.log(`[watchdog] Started monitoring leader health (${this.config.agentName})`);
|
|
45
|
+
this.checkInterval = setInterval(async () => {
|
|
46
|
+
try {
|
|
47
|
+
await this.checkLeaderHealth();
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
console.error('[watchdog] Check error:', err);
|
|
51
|
+
this.emit('error', err);
|
|
52
|
+
}
|
|
53
|
+
}, this.config.checkIntervalMs);
|
|
54
|
+
// Initial check
|
|
55
|
+
this.checkLeaderHealth().catch((err) => {
|
|
56
|
+
console.error('[watchdog] Initial check error:', err);
|
|
57
|
+
});
|
|
58
|
+
this.emit('started');
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Stop watching
|
|
62
|
+
*/
|
|
63
|
+
stop() {
|
|
64
|
+
if (!this.isRunning)
|
|
65
|
+
return;
|
|
66
|
+
this.isRunning = false;
|
|
67
|
+
if (this.checkInterval) {
|
|
68
|
+
clearInterval(this.checkInterval);
|
|
69
|
+
this.checkInterval = undefined;
|
|
70
|
+
}
|
|
71
|
+
console.log(`[watchdog] Stopped monitoring (${this.config.agentName})`);
|
|
72
|
+
this.emit('stopped');
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Check if current leader is healthy
|
|
76
|
+
*/
|
|
77
|
+
async checkLeaderHealth() {
|
|
78
|
+
const heartbeat = await StatelessLeadCoordinator.readHeartbeat(this.config.beadsDir);
|
|
79
|
+
// No leader - trigger election
|
|
80
|
+
if (!heartbeat) {
|
|
81
|
+
console.log('[watchdog] No leader detected, triggering election');
|
|
82
|
+
await this.triggerElection('no_leader');
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
// Check if this is us
|
|
86
|
+
if (heartbeat.leadId === this.config.agentId) {
|
|
87
|
+
this.isLeader = true;
|
|
88
|
+
this.currentLeader = heartbeat;
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
this.isLeader = false;
|
|
92
|
+
// Check if stale
|
|
93
|
+
const age = Date.now() - heartbeat.timestamp;
|
|
94
|
+
if (age > this.config.staleThresholdMs) {
|
|
95
|
+
console.log(`[watchdog] Leader ${heartbeat.leadName} is stale (${Math.round(age / 1000)}s old)`);
|
|
96
|
+
this.emit('leaderStale', { leader: heartbeat, age });
|
|
97
|
+
await this.triggerElection('stale_leader');
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
// Leader is healthy
|
|
101
|
+
if (!this.currentLeader || this.currentLeader.leadId !== heartbeat.leadId) {
|
|
102
|
+
console.log(`[watchdog] Leader detected: ${heartbeat.leadName}`);
|
|
103
|
+
this.emit('leaderDetected', heartbeat);
|
|
104
|
+
}
|
|
105
|
+
this.currentLeader = heartbeat;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Trigger leader election
|
|
109
|
+
*/
|
|
110
|
+
async triggerElection(reason) {
|
|
111
|
+
console.log(`[watchdog] Triggering election (reason: ${reason})`);
|
|
112
|
+
this.emit('electionStarted', { reason });
|
|
113
|
+
const result = await this.electLeader();
|
|
114
|
+
if (result.method === 'none') {
|
|
115
|
+
console.log('[watchdog] No candidates for election');
|
|
116
|
+
this.emit('electionFailed', { reason: 'no_candidates' });
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
console.log(`[watchdog] Election result: ${result.winner} (method: ${result.method})`);
|
|
120
|
+
this.emit('electionComplete', result);
|
|
121
|
+
// If we won, become leader
|
|
122
|
+
if (result.winnerId === this.config.agentId) {
|
|
123
|
+
console.log(`[watchdog] This agent (${this.config.agentName}) won the election, becoming leader`);
|
|
124
|
+
this.isLeader = true;
|
|
125
|
+
await this.config.onBecomeLeader();
|
|
126
|
+
this.emit('becameLeader');
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Simple leader election: oldest healthy agent wins
|
|
131
|
+
*/
|
|
132
|
+
async electLeader() {
|
|
133
|
+
const candidates = await this.config.getHealthyAgents();
|
|
134
|
+
if (candidates.length === 0) {
|
|
135
|
+
return {
|
|
136
|
+
winner: '',
|
|
137
|
+
winnerId: '',
|
|
138
|
+
candidates: [],
|
|
139
|
+
method: 'none',
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
// Sort by spawn time (oldest first)
|
|
143
|
+
candidates.sort((a, b) => a.spawnedAt.getTime() - b.spawnedAt.getTime());
|
|
144
|
+
const winner = candidates[0];
|
|
145
|
+
return {
|
|
146
|
+
winner: winner.name,
|
|
147
|
+
winnerId: winner.id,
|
|
148
|
+
candidates: candidates.map((c) => c.name),
|
|
149
|
+
method: 'oldest',
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Check if this agent is currently the leader
|
|
154
|
+
*/
|
|
155
|
+
isCurrentLeader() {
|
|
156
|
+
return this.isLeader;
|
|
157
|
+
}
|
|
158
|
+
/**
|
|
159
|
+
* Get current leader info
|
|
160
|
+
*/
|
|
161
|
+
getCurrentLeader() {
|
|
162
|
+
return this.currentLeader;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Get watchdog status
|
|
166
|
+
*/
|
|
167
|
+
getStatus() {
|
|
168
|
+
return {
|
|
169
|
+
isRunning: this.isRunning,
|
|
170
|
+
isLeader: this.isLeader,
|
|
171
|
+
currentLeader: this.currentLeader,
|
|
172
|
+
agentName: this.config.agentName,
|
|
173
|
+
};
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Create a leader watchdog with defaults
|
|
178
|
+
*/
|
|
179
|
+
export function createLeaderWatchdog(beadsDir, agentName, agentId, callbacks) {
|
|
180
|
+
return new LeaderWatchdog({
|
|
181
|
+
beadsDir,
|
|
182
|
+
agentName,
|
|
183
|
+
agentId,
|
|
184
|
+
...callbacks,
|
|
185
|
+
checkIntervalMs: 5000,
|
|
186
|
+
staleThresholdMs: 30000,
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
//# sourceMappingURL=leader-watchdog.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"leader-watchdog.js","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AAU,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC;YACzC,MAAM,EAAE,QAAQ;SACjB,CAAC;IACJ,CAAC;IAED;;OAEG;IACH,eAAe;QACb,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED;;OAEG;IACH,gBAAgB;QACd,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAED;;OAEG;IACH,SAAS;QAMP,OAAO;YACL,SAAS,EAAE,IAAI,CAAC,SAAS;YACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,SAAS,EAAE,IAAI,CAAC,MAAM,CAAC,SAAS;SACjC,CAAC;IACJ,CAAC;CACF;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB,CAClC,QAAgB,EAChB,SAAiB,EACjB,OAAe,EACf,SAGC;IAED,OAAO,IAAI,cAAc,CAAC;QACxB,QAAQ;QACR,SAAS;QACT,OAAO;QACP,GAAG,SAAS;QACZ,eAAe,EAAE,IAAI;QACrB,gBAAgB,EAAE,KAAK;KACxB,CAAC,CAAC;AACL,CAAC"}
|
package/dist/logger.d.ts
ADDED
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Logger
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent, structured logging across agent-relay components.
|
|
5
|
+
* - JSON format for machine parsing
|
|
6
|
+
* - Log levels with filtering
|
|
7
|
+
* - Context propagation (correlation IDs, agent names)
|
|
8
|
+
* - File rotation support
|
|
9
|
+
*/
|
|
10
|
+
import { EventEmitter } from 'events';
|
|
11
|
+
export type LogLevel = 'debug' | 'info' | 'warn' | 'error' | 'fatal';
|
|
12
|
+
export interface LogEntry {
|
|
13
|
+
timestamp: string;
|
|
14
|
+
level: LogLevel;
|
|
15
|
+
component: string;
|
|
16
|
+
message: string;
|
|
17
|
+
correlationId?: string;
|
|
18
|
+
agentName?: string;
|
|
19
|
+
pid?: number;
|
|
20
|
+
duration?: number;
|
|
21
|
+
error?: {
|
|
22
|
+
name: string;
|
|
23
|
+
message: string;
|
|
24
|
+
stack?: string;
|
|
25
|
+
};
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
export interface LoggerConfig {
|
|
29
|
+
level: LogLevel;
|
|
30
|
+
json: boolean;
|
|
31
|
+
file?: string;
|
|
32
|
+
maxFileSize?: number;
|
|
33
|
+
maxFiles?: number;
|
|
34
|
+
console: boolean;
|
|
35
|
+
}
|
|
36
|
+
export declare class Logger extends EventEmitter {
|
|
37
|
+
private config;
|
|
38
|
+
private component;
|
|
39
|
+
private context;
|
|
40
|
+
private fileStream?;
|
|
41
|
+
private currentFileSize;
|
|
42
|
+
constructor(component: string, config?: Partial<LoggerConfig>);
|
|
43
|
+
/**
|
|
44
|
+
* Create a child logger with additional context
|
|
45
|
+
*/
|
|
46
|
+
child(context: Record<string, unknown>): Logger;
|
|
47
|
+
/**
|
|
48
|
+
* Set context that will be included in all log entries
|
|
49
|
+
*/
|
|
50
|
+
setContext(context: Record<string, unknown>): void;
|
|
51
|
+
/**
|
|
52
|
+
* Log at debug level
|
|
53
|
+
*/
|
|
54
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
55
|
+
/**
|
|
56
|
+
* Log at info level
|
|
57
|
+
*/
|
|
58
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
59
|
+
/**
|
|
60
|
+
* Log at warn level
|
|
61
|
+
*/
|
|
62
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
63
|
+
/**
|
|
64
|
+
* Log at error level
|
|
65
|
+
*/
|
|
66
|
+
error(message: string, context?: Record<string, unknown>): void;
|
|
67
|
+
/**
|
|
68
|
+
* Log at fatal level
|
|
69
|
+
*/
|
|
70
|
+
fatal(message: string, context?: Record<string, unknown>): void;
|
|
71
|
+
/**
|
|
72
|
+
* Log with timing (returns function to end timing)
|
|
73
|
+
*/
|
|
74
|
+
time(message: string, context?: Record<string, unknown>): () => void;
|
|
75
|
+
/**
|
|
76
|
+
* Log an error with stack trace
|
|
77
|
+
*/
|
|
78
|
+
logError(error: Error, message?: string, context?: Record<string, unknown>): void;
|
|
79
|
+
/**
|
|
80
|
+
* Core log method
|
|
81
|
+
*/
|
|
82
|
+
private log;
|
|
83
|
+
/**
|
|
84
|
+
* Write to console
|
|
85
|
+
*/
|
|
86
|
+
private writeConsole;
|
|
87
|
+
/**
|
|
88
|
+
* Write to file with rotation
|
|
89
|
+
*/
|
|
90
|
+
private writeFile;
|
|
91
|
+
/**
|
|
92
|
+
* Initialize file stream
|
|
93
|
+
*/
|
|
94
|
+
private initFileStream;
|
|
95
|
+
/**
|
|
96
|
+
* Rotate log file
|
|
97
|
+
*/
|
|
98
|
+
private rotateFile;
|
|
99
|
+
/**
|
|
100
|
+
* Close the logger
|
|
101
|
+
*/
|
|
102
|
+
close(): void;
|
|
103
|
+
}
|
|
104
|
+
export declare function configure(config: Partial<LoggerConfig>): void;
|
|
105
|
+
export declare function createLogger(component: string, config?: Partial<LoggerConfig>): Logger;
|
|
106
|
+
export declare const loggers: {
|
|
107
|
+
daemon: () => Logger;
|
|
108
|
+
spawner: () => Logger;
|
|
109
|
+
router: () => Logger;
|
|
110
|
+
agent: (name: string) => Logger;
|
|
111
|
+
health: () => Logger;
|
|
112
|
+
connection: (id: string) => Logger;
|
|
113
|
+
};
|
|
114
|
+
//# sourceMappingURL=logger.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.d.ts","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAItC,MAAM,MAAM,QAAQ,GAAG,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC;AAErE,MAAM,WAAW,QAAQ;IACvB,SAAS,EAAE,MAAM,CA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MAAM;CACxB,CAAC"}
|
package/dist/logger.js
ADDED
|
@@ -0,0 +1,250 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Logger
|
|
3
|
+
*
|
|
4
|
+
* Provides consistent, structured logging across agent-relay components.
|
|
5
|
+
* - JSON format for machine parsing
|
|
6
|
+
* - Log levels with filtering
|
|
7
|
+
* - Context propagation (correlation IDs, agent names)
|
|
8
|
+
* - File rotation support
|
|
9
|
+
*/
|
|
10
|
+
import { EventEmitter } from 'events';
|
|
11
|
+
import * as fs from 'fs';
|
|
12
|
+
import * as path from 'path';
|
|
13
|
+
const LOG_LEVELS = {
|
|
14
|
+
debug: 0,
|
|
15
|
+
info: 1,
|
|
16
|
+
warn: 2,
|
|
17
|
+
error: 3,
|
|
18
|
+
fatal: 4,
|
|
19
|
+
};
|
|
20
|
+
const LEVEL_COLORS = {
|
|
21
|
+
debug: '\x1b[90m', // gray
|
|
22
|
+
info: '\x1b[36m', // cyan
|
|
23
|
+
warn: '\x1b[33m', // yellow
|
|
24
|
+
error: '\x1b[31m', // red
|
|
25
|
+
fatal: '\x1b[35m', // magenta
|
|
26
|
+
};
|
|
27
|
+
const RESET = '\x1b[0m';
|
|
28
|
+
const DEFAULT_CONFIG = {
|
|
29
|
+
level: 'info',
|
|
30
|
+
json: process.env.NODE_ENV === 'production',
|
|
31
|
+
console: true,
|
|
32
|
+
maxFileSize: 10 * 1024 * 1024, // 10MB
|
|
33
|
+
maxFiles: 5,
|
|
34
|
+
};
|
|
35
|
+
export class Logger extends EventEmitter {
|
|
36
|
+
config;
|
|
37
|
+
component;
|
|
38
|
+
context = {};
|
|
39
|
+
fileStream;
|
|
40
|
+
currentFileSize = 0;
|
|
41
|
+
constructor(component, config = {}) {
|
|
42
|
+
super();
|
|
43
|
+
this.component = component;
|
|
44
|
+
this.config = { ...DEFAULT_CONFIG, ...config };
|
|
45
|
+
if (this.config.file) {
|
|
46
|
+
this.initFileStream();
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Create a child logger with additional context
|
|
51
|
+
*/
|
|
52
|
+
child(context) {
|
|
53
|
+
const child = new Logger(this.component, this.config);
|
|
54
|
+
child.context = { ...this.context, ...context };
|
|
55
|
+
return child;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Set context that will be included in all log entries
|
|
59
|
+
*/
|
|
60
|
+
setContext(context) {
|
|
61
|
+
this.context = { ...this.context, ...context };
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Log at debug level
|
|
65
|
+
*/
|
|
66
|
+
debug(message, context) {
|
|
67
|
+
this.log('debug', message, context);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Log at info level
|
|
71
|
+
*/
|
|
72
|
+
info(message, context) {
|
|
73
|
+
this.log('info', message, context);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Log at warn level
|
|
77
|
+
*/
|
|
78
|
+
warn(message, context) {
|
|
79
|
+
this.log('warn', message, context);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Log at error level
|
|
83
|
+
*/
|
|
84
|
+
error(message, context) {
|
|
85
|
+
this.log('error', message, context);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Log at fatal level
|
|
89
|
+
*/
|
|
90
|
+
fatal(message, context) {
|
|
91
|
+
this.log('fatal', message, context);
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Log with timing (returns function to end timing)
|
|
95
|
+
*/
|
|
96
|
+
time(message, context) {
|
|
97
|
+
const start = Date.now();
|
|
98
|
+
return () => {
|
|
99
|
+
const duration = Date.now() - start;
|
|
100
|
+
this.info(message, { ...context, duration });
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Log an error with stack trace
|
|
105
|
+
*/
|
|
106
|
+
logError(error, message, context) {
|
|
107
|
+
this.log('error', message || error.message, {
|
|
108
|
+
...context,
|
|
109
|
+
error: {
|
|
110
|
+
name: error.name,
|
|
111
|
+
message: error.message,
|
|
112
|
+
stack: error.stack,
|
|
113
|
+
},
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Core log method
|
|
118
|
+
*/
|
|
119
|
+
log(level, message, context) {
|
|
120
|
+
if (LOG_LEVELS[level] < LOG_LEVELS[this.config.level]) {
|
|
121
|
+
return;
|
|
122
|
+
}
|
|
123
|
+
const entry = {
|
|
124
|
+
timestamp: new Date().toISOString(),
|
|
125
|
+
level,
|
|
126
|
+
component: this.component,
|
|
127
|
+
message,
|
|
128
|
+
...this.context,
|
|
129
|
+
...context,
|
|
130
|
+
};
|
|
131
|
+
// Emit for external handlers
|
|
132
|
+
this.emit('log', entry);
|
|
133
|
+
// Console output
|
|
134
|
+
if (this.config.console) {
|
|
135
|
+
this.writeConsole(entry);
|
|
136
|
+
}
|
|
137
|
+
// File output
|
|
138
|
+
if (this.fileStream) {
|
|
139
|
+
this.writeFile(entry);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Write to console
|
|
144
|
+
*/
|
|
145
|
+
writeConsole(entry) {
|
|
146
|
+
if (this.config.json) {
|
|
147
|
+
console.log(JSON.stringify(entry));
|
|
148
|
+
}
|
|
149
|
+
else {
|
|
150
|
+
const color = LEVEL_COLORS[entry.level];
|
|
151
|
+
const levelStr = entry.level.toUpperCase().padEnd(5);
|
|
152
|
+
const componentStr = `[${entry.component}]`.padEnd(20);
|
|
153
|
+
let line = `${entry.timestamp} ${color}${levelStr}${RESET} ${componentStr} ${entry.message}`;
|
|
154
|
+
// Add context fields (exclude standard log entry fields)
|
|
155
|
+
const { timestamp: _t, level: _l, component: _c, message: _m, ...contextFields } = entry;
|
|
156
|
+
if (Object.keys(contextFields).length > 0) {
|
|
157
|
+
line += ` ${JSON.stringify(contextFields)}`;
|
|
158
|
+
}
|
|
159
|
+
console.log(line);
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Write to file with rotation
|
|
164
|
+
*/
|
|
165
|
+
writeFile(entry) {
|
|
166
|
+
if (!this.fileStream)
|
|
167
|
+
return;
|
|
168
|
+
const line = JSON.stringify(entry) + '\n';
|
|
169
|
+
const lineBytes = Buffer.byteLength(line);
|
|
170
|
+
// Check if rotation needed
|
|
171
|
+
if (this.config.maxFileSize &&
|
|
172
|
+
this.currentFileSize + lineBytes > this.config.maxFileSize) {
|
|
173
|
+
this.rotateFile();
|
|
174
|
+
}
|
|
175
|
+
this.fileStream.write(line);
|
|
176
|
+
this.currentFileSize += lineBytes;
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Initialize file stream
|
|
180
|
+
*/
|
|
181
|
+
initFileStream() {
|
|
182
|
+
if (!this.config.file)
|
|
183
|
+
return;
|
|
184
|
+
const dir = path.dirname(this.config.file);
|
|
185
|
+
if (!fs.existsSync(dir)) {
|
|
186
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
187
|
+
}
|
|
188
|
+
// Get current file size
|
|
189
|
+
if (fs.existsSync(this.config.file)) {
|
|
190
|
+
const stats = fs.statSync(this.config.file);
|
|
191
|
+
this.currentFileSize = stats.size;
|
|
192
|
+
}
|
|
193
|
+
this.fileStream = fs.createWriteStream(this.config.file, { flags: 'a' });
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Rotate log file
|
|
197
|
+
*/
|
|
198
|
+
rotateFile() {
|
|
199
|
+
if (!this.config.file || !this.fileStream)
|
|
200
|
+
return;
|
|
201
|
+
this.fileStream.end();
|
|
202
|
+
// Rotate existing files
|
|
203
|
+
for (let i = (this.config.maxFiles || 5) - 1; i >= 1; i--) {
|
|
204
|
+
const oldPath = `${this.config.file}.${i}`;
|
|
205
|
+
const newPath = `${this.config.file}.${i + 1}`;
|
|
206
|
+
if (fs.existsSync(oldPath)) {
|
|
207
|
+
if (i === (this.config.maxFiles || 5) - 1) {
|
|
208
|
+
fs.unlinkSync(oldPath); // Delete oldest
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
fs.renameSync(oldPath, newPath);
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
// Rename current to .1
|
|
216
|
+
if (fs.existsSync(this.config.file)) {
|
|
217
|
+
fs.renameSync(this.config.file, `${this.config.file}.1`);
|
|
218
|
+
}
|
|
219
|
+
// Create new stream
|
|
220
|
+
this.currentFileSize = 0;
|
|
221
|
+
this.fileStream = fs.createWriteStream(this.config.file, { flags: 'a' });
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* Close the logger
|
|
225
|
+
*/
|
|
226
|
+
close() {
|
|
227
|
+
if (this.fileStream) {
|
|
228
|
+
this.fileStream.end();
|
|
229
|
+
this.fileStream = undefined;
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Logger factory with global configuration
|
|
234
|
+
let globalConfig = {};
|
|
235
|
+
export function configure(config) {
|
|
236
|
+
globalConfig = config;
|
|
237
|
+
}
|
|
238
|
+
export function createLogger(component, config) {
|
|
239
|
+
return new Logger(component, { ...globalConfig, ...config });
|
|
240
|
+
}
|
|
241
|
+
// Pre-configured loggers for common components
|
|
242
|
+
export const loggers = {
|
|
243
|
+
daemon: () => createLogger('daemon'),
|
|
244
|
+
spawner: () => createLogger('spawner'),
|
|
245
|
+
router: () => createLogger('router'),
|
|
246
|
+
agent: (name) => createLogger('agent').child({ agentName: name }),
|
|
247
|
+
health: () => createLogger('health-monitor'),
|
|
248
|
+
connection: (id) => createLogger('connection').child({ connectionId: id }),
|
|
249
|
+
};
|
|
250
|
+
//# sourceMappingURL=logger.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"logger.js","sourceRoot":"","sources":["../src/logger.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AACtC,OAAO,KAAK,EAAE,MAAM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