feat(telemetry): report openclaw and plugin versions separately

- Report remote OpenClaw CLI version as openclaw_version
- Report harborforge-monitor plugin version as plugin_version
- Pass plugin version from plugin runtime to sidecar
- Read live config via api.pluginConfig/api.config helper
This commit is contained in:
zhi
2026-03-20 07:23:18 +00:00
parent 006784db63
commit 040cde8cad
6 changed files with 73 additions and 6 deletions

View File

@@ -22,7 +22,7 @@ const CONFIG = {
httpFallbackIntervalSec: parseInt(process.env.HF_MONITOR_HTTP_FALLBACK_INTERVAL || '60', 10),
logLevel: process.env.HF_MONITOR_LOG_LEVEL || 'info',
openclawPath,
openclawVersion: process.env.OPENCLAW_VERSION || 'unknown',
pluginVersion: process.env.HF_MONITOR_PLUGIN_VERSION || 'unknown',
cachePath: process.env.HF_MONITOR_CACHE_PATH || `${openclawPath}/telemetry_cache.json`,
maxCacheSize: parseInt(process.env.HF_MONITOR_MAX_CACHE_SIZE || '100', 10),
};
@@ -40,6 +40,7 @@ let wsConnection = null;
let lastSuccessfulSend = null;
let consecutiveFailures = 0;
let isShuttingDown = false;
let cachedOpenclawVersion = null;
/**
* Collect system metrics
@@ -136,14 +137,33 @@ function parseSizeToGB(size) {
return num;
}
async function resolveOpenclawVersion() {
if (cachedOpenclawVersion) return cachedOpenclawVersion;
try {
const { stdout } = await execAsync('openclaw --version');
const version = stdout.trim();
cachedOpenclawVersion = version || 'unknown';
return cachedOpenclawVersion;
} catch (err) {
log.debug('Failed to resolve OpenClaw version:', err.message);
cachedOpenclawVersion = 'unknown';
return cachedOpenclawVersion;
}
}
/**
* Collect OpenClaw status
*/
async function collectOpenclawStatus() {
try {
const agents = await getOpenclawAgents();
const [agents, openclawVersion] = await Promise.all([
getOpenclawAgents(),
resolveOpenclawVersion(),
]);
return {
version: CONFIG.openclawVersion,
openclawVersion,
pluginVersion: CONFIG.pluginVersion,
agent_count: agents.length,
agents: agents.map(a => ({
id: a.id,
@@ -153,7 +173,12 @@ async function collectOpenclawStatus() {
};
} catch (err) {
log.debug('Failed to collect OpenClaw status:', err.message);
return { version: CONFIG.openclawVersion, agent_count: 0, agents: [] };
return {
openclawVersion: await resolveOpenclawVersion(),
pluginVersion: CONFIG.pluginVersion,
agent_count: 0,
agents: [],
};
}
}
@@ -186,7 +211,8 @@ async function buildPayload() {
identifier: CONFIG.identifier,
timestamp: new Date().toISOString(),
...system,
openclaw_version: openclaw.version,
openclaw_version: openclaw.openclawVersion,
plugin_version: openclaw.pluginVersion,
agents: openclaw.agents,
};
}
@@ -279,6 +305,7 @@ log.info('Config:', {
backendUrl: CONFIG.backendUrl,
reportIntervalSec: CONFIG.reportIntervalSec,
hasApiKey: !!CONFIG.apiKey,
pluginVersion: CONFIG.pluginVersion,
});
if (!CONFIG.apiKey) {