- Added telemetry utility to capture application events and metrics. - Integrated PostHog for event tracking with distinct user identification. - Implemented telemetry initialization, event capturing, and shutdown procedures. feat: add UV environment setup for Python management - Created utilities to manage Python installation and configuration. - Implemented network optimization checks for Python installation mirrors. - Added functions to set up managed Python environments with error handling. feat: enhance host API communication with token management - Introduced host API token retrieval and management for secure requests. - Updated host API fetch functions to include token in headers. - Added support for creating event sources with authentication. test: add comprehensive tests for gateway protocol and startup helpers - Implemented unit tests for gateway protocol helpers, event dispatching, and state management. - Added tests for startup recovery strategies and process policies. - Ensured coverage for connection monitoring and restart governance logic.
53 lines
1.6 KiB
TypeScript
53 lines
1.6 KiB
TypeScript
export type GatewayStderrClassification = {
|
|
level: 'drop' | 'debug' | 'warn';
|
|
normalized: string;
|
|
};
|
|
|
|
const MAX_STDERR_LINES = 120;
|
|
|
|
export function classifyGatewayStderrMessage(message: string): GatewayStderrClassification {
|
|
const normalized = message.trim();
|
|
if (!normalized) {
|
|
return { level: 'drop', normalized };
|
|
}
|
|
|
|
if (normalized.includes('openclaw-control-ui') && normalized.includes('token_mismatch')) {
|
|
return { level: 'drop', normalized };
|
|
}
|
|
if (normalized.includes('closed before connect') && normalized.includes('token mismatch')) {
|
|
return { level: 'drop', normalized };
|
|
}
|
|
if (normalized.includes('[ws] closed before connect') && normalized.includes('code=1005')) {
|
|
return { level: 'debug', normalized };
|
|
}
|
|
if (normalized.includes('ExperimentalWarning')) {
|
|
return { level: 'debug', normalized };
|
|
}
|
|
if (normalized.includes('DeprecationWarning')) {
|
|
return { level: 'debug', normalized };
|
|
}
|
|
if (normalized.includes('Debugger attached')) {
|
|
return { level: 'debug', normalized };
|
|
}
|
|
if (normalized.includes('Config warnings:')) {
|
|
return { level: 'debug', normalized };
|
|
}
|
|
if (normalized.includes('node: --require is not allowed in NODE_OPTIONS')) {
|
|
return { level: 'debug', normalized };
|
|
}
|
|
|
|
return { level: 'warn', normalized };
|
|
}
|
|
|
|
export function recordGatewayStartupStderrLine(lines: string[], line: string): void {
|
|
const normalized = line.trim();
|
|
if (!normalized) {
|
|
return;
|
|
}
|
|
|
|
lines.push(normalized);
|
|
if (lines.length > MAX_STDERR_LINES) {
|
|
lines.splice(0, lines.length - MAX_STDERR_LINES);
|
|
}
|
|
}
|