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:
15
plugin/core/live-config.d.ts
vendored
Normal file
15
plugin/core/live-config.d.ts
vendored
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
export interface HarborForgeMonitorConfig {
|
||||||
|
enabled?: boolean;
|
||||||
|
backendUrl?: string;
|
||||||
|
identifier?: string;
|
||||||
|
apiKey?: string;
|
||||||
|
reportIntervalSec?: number;
|
||||||
|
httpFallbackIntervalSec?: number;
|
||||||
|
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
||||||
|
}
|
||||||
|
interface OpenClawPluginApiLike {
|
||||||
|
config?: Record<string, unknown>;
|
||||||
|
}
|
||||||
|
export declare function getLivePluginConfig(api: OpenClawPluginApiLike, fallback: HarborForgeMonitorConfig): HarborForgeMonitorConfig;
|
||||||
|
export {};
|
||||||
|
//# sourceMappingURL=live-config.d.ts.map
|
||||||
1
plugin/core/live-config.d.ts.map
Normal file
1
plugin/core/live-config.d.ts.map
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"live-config.d.ts","sourceRoot":"","sources":["live-config.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,wBAAwB;IACvC,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,uBAAuB,CAAC,EAAE,MAAM,CAAC;IACjC,QAAQ,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC;CAChD;AAED,UAAU,qBAAqB;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,wBAAgB,mBAAmB,CACjC,GAAG,EAAE,qBAAqB,EAC1B,QAAQ,EAAE,wBAAwB,GACjC,wBAAwB,CAqB1B"}
|
||||||
23
plugin/core/live-config.js
Normal file
23
plugin/core/live-config.js
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
"use strict";
|
||||||
|
Object.defineProperty(exports, "__esModule", { value: true });
|
||||||
|
exports.getLivePluginConfig = getLivePluginConfig;
|
||||||
|
function getLivePluginConfig(api, fallback) {
|
||||||
|
const root = api.config || {};
|
||||||
|
const plugins = root.plugins || {};
|
||||||
|
const entries = plugins.entries || {};
|
||||||
|
const entry = entries['harborforge-monitor'] || {};
|
||||||
|
const cfg = entry.config || {};
|
||||||
|
if (Object.keys(cfg).length > 0 || Object.keys(entry).length > 0) {
|
||||||
|
return {
|
||||||
|
...fallback,
|
||||||
|
...cfg,
|
||||||
|
enabled: typeof cfg.enabled === 'boolean'
|
||||||
|
? cfg.enabled
|
||||||
|
: typeof entry.enabled === 'boolean'
|
||||||
|
? entry.enabled
|
||||||
|
: fallback.enabled,
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return fallback;
|
||||||
|
}
|
||||||
|
//# sourceMappingURL=live-config.js.map
|
||||||
1
plugin/core/live-config.js.map
Normal file
1
plugin/core/live-config.js.map
Normal file
@@ -0,0 +1 @@
|
|||||||
|
{"version":3,"file":"live-config.js","sourceRoot":"","sources":["live-config.ts"],"names":[],"mappings":";;AAcA,kDAwBC;AAxBD,SAAgB,mBAAmB,CACjC,GAA0B,EAC1B,QAAkC;IAElC,MAAM,IAAI,GAAI,GAAG,CAAC,MAAkC,IAAI,EAAE,CAAC;IAC3D,MAAM,OAAO,GAAI,IAAI,CAAC,OAAmC,IAAI,EAAE,CAAC;IAChE,MAAM,OAAO,GAAI,OAAO,CAAC,OAAmC,IAAI,EAAE,CAAC;IACnE,MAAM,KAAK,GAAI,OAAO,CAAC,qBAAqB,CAA6B,IAAI,EAAE,CAAC;IAChF,MAAM,GAAG,GAAI,KAAK,CAAC,MAAkC,IAAI,EAAE,CAAC;IAE5D,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjE,OAAO;YACL,GAAG,QAAQ;YACX,GAAG,GAAG;YACN,OAAO,EACL,OAAO,GAAG,CAAC,OAAO,KAAK,SAAS;gBAC9B,CAAC,CAAC,GAAG,CAAC,OAAO;gBACb,CAAC,CAAC,OAAO,KAAK,CAAC,OAAO,KAAK,SAAS;oBAClC,CAAC,CAAC,KAAK,CAAC,OAAO;oBACf,CAAC,CAAC,QAAQ,CAAC,OAAO;SACG,CAAC;IAChC,CAAC;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
||||||
@@ -92,7 +92,7 @@ export default {
|
|||||||
HF_MONITOR_HTTP_FALLBACK_INTERVAL: String(live.httpFallbackIntervalSec || 60),
|
HF_MONITOR_HTTP_FALLBACK_INTERVAL: String(live.httpFallbackIntervalSec || 60),
|
||||||
HF_MONITOR_LOG_LEVEL: live.logLevel || 'info',
|
HF_MONITOR_LOG_LEVEL: live.logLevel || 'info',
|
||||||
OPENCLAW_PATH: process.env.OPENCLAW_PATH || join(process.env.HOME || '/root', '.openclaw'),
|
OPENCLAW_PATH: process.env.OPENCLAW_PATH || join(process.env.HOME || '/root', '.openclaw'),
|
||||||
OPENCLAW_VERSION: api.version || 'unknown',
|
HF_MONITOR_PLUGIN_VERSION: api.version || 'unknown',
|
||||||
};
|
};
|
||||||
|
|
||||||
sidecar = spawn('node', [serverPath], {
|
sidecar = spawn('node', [serverPath], {
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ const CONFIG = {
|
|||||||
httpFallbackIntervalSec: parseInt(process.env.HF_MONITOR_HTTP_FALLBACK_INTERVAL || '60', 10),
|
httpFallbackIntervalSec: parseInt(process.env.HF_MONITOR_HTTP_FALLBACK_INTERVAL || '60', 10),
|
||||||
logLevel: process.env.HF_MONITOR_LOG_LEVEL || 'info',
|
logLevel: process.env.HF_MONITOR_LOG_LEVEL || 'info',
|
||||||
openclawPath,
|
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`,
|
cachePath: process.env.HF_MONITOR_CACHE_PATH || `${openclawPath}/telemetry_cache.json`,
|
||||||
maxCacheSize: parseInt(process.env.HF_MONITOR_MAX_CACHE_SIZE || '100', 10),
|
maxCacheSize: parseInt(process.env.HF_MONITOR_MAX_CACHE_SIZE || '100', 10),
|
||||||
};
|
};
|
||||||
@@ -40,6 +40,7 @@ let wsConnection = null;
|
|||||||
let lastSuccessfulSend = null;
|
let lastSuccessfulSend = null;
|
||||||
let consecutiveFailures = 0;
|
let consecutiveFailures = 0;
|
||||||
let isShuttingDown = false;
|
let isShuttingDown = false;
|
||||||
|
let cachedOpenclawVersion = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Collect system metrics
|
* Collect system metrics
|
||||||
@@ -136,14 +137,33 @@ function parseSizeToGB(size) {
|
|||||||
return num;
|
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
|
* Collect OpenClaw status
|
||||||
*/
|
*/
|
||||||
async function collectOpenclawStatus() {
|
async function collectOpenclawStatus() {
|
||||||
try {
|
try {
|
||||||
const agents = await getOpenclawAgents();
|
const [agents, openclawVersion] = await Promise.all([
|
||||||
|
getOpenclawAgents(),
|
||||||
|
resolveOpenclawVersion(),
|
||||||
|
]);
|
||||||
return {
|
return {
|
||||||
version: CONFIG.openclawVersion,
|
openclawVersion,
|
||||||
|
pluginVersion: CONFIG.pluginVersion,
|
||||||
agent_count: agents.length,
|
agent_count: agents.length,
|
||||||
agents: agents.map(a => ({
|
agents: agents.map(a => ({
|
||||||
id: a.id,
|
id: a.id,
|
||||||
@@ -153,7 +173,12 @@ async function collectOpenclawStatus() {
|
|||||||
};
|
};
|
||||||
} catch (err) {
|
} catch (err) {
|
||||||
log.debug('Failed to collect OpenClaw status:', err.message);
|
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,
|
identifier: CONFIG.identifier,
|
||||||
timestamp: new Date().toISOString(),
|
timestamp: new Date().toISOString(),
|
||||||
...system,
|
...system,
|
||||||
openclaw_version: openclaw.version,
|
openclaw_version: openclaw.openclawVersion,
|
||||||
|
plugin_version: openclaw.pluginVersion,
|
||||||
agents: openclaw.agents,
|
agents: openclaw.agents,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
@@ -279,6 +305,7 @@ log.info('Config:', {
|
|||||||
backendUrl: CONFIG.backendUrl,
|
backendUrl: CONFIG.backendUrl,
|
||||||
reportIntervalSec: CONFIG.reportIntervalSec,
|
reportIntervalSec: CONFIG.reportIntervalSec,
|
||||||
hasApiKey: !!CONFIG.apiKey,
|
hasApiKey: !!CONFIG.apiKey,
|
||||||
|
pluginVersion: CONFIG.pluginVersion,
|
||||||
});
|
});
|
||||||
|
|
||||||
if (!CONFIG.apiKey) {
|
if (!CONFIG.apiKey) {
|
||||||
|
|||||||
Reference in New Issue
Block a user