diff --git a/plugin/index.ts b/plugin/index.ts index 93b5f7b..ecc0287 100644 --- a/plugin/index.ts +++ b/plugin/index.ts @@ -14,7 +14,7 @@ import { hostname, freemem, totalmem, uptime, loadavg, platform } from 'os'; import { getPluginConfig } from './core/config'; import { MonitorBridgeClient, type OpenClawMeta } from './core/monitor-bridge'; -import { listOpenClawAgents } from './core/openclaw-agents'; +import type { OpenClawAgentInfo } from './core/openclaw-agents'; import { registerGatewayStartHook } from './hooks/gateway-start'; import { registerGatewayStopHook } from './hooks/gateway-stop'; import { @@ -32,6 +32,12 @@ interface PluginAPI { warn: (...args: any[]) => void; }; version?: string; + runtime?: { + version?: string; + config?: { + loadConfig?: () => any; + }; + }; config?: Record; pluginConfig?: Record; on: (event: string, handler: () => void) => void; @@ -96,7 +102,7 @@ export default { avg15: load[2], }, openclaw: { - version: process.env.OPENCLAW_SERVICE_VERSION || api.version || 'unknown', + version: api.runtime?.version || api.version || 'unknown', pluginVersion: '0.3.1', // Bumped for PLG-CAL-004 }, timestamp: new Date().toISOString(), @@ -118,10 +124,21 @@ export default { const bridgeClient = getBridgeClient(); if (!bridgeClient) return; + let agentNames: string[] = []; + try { + const cfg = api.runtime?.config?.loadConfig?.(); + const agentsList = cfg?.agents?.list; + if (Array.isArray(agentsList)) { + agentNames = agentsList + .map((a: any) => typeof a === 'string' ? a : a?.name) + .filter(Boolean); + } + } catch { /* non-fatal */ } + const meta: OpenClawMeta = { - version: process.env.OPENCLAW_SERVICE_VERSION || api.version || 'unknown', + version: api.runtime?.version || api.version || 'unknown', plugin_version: '0.3.1', - agents: await listOpenClawAgents(logger), + agents: agentNames.map(name => ({ name })), }; const ok = await bridgeClient.pushOpenClawMeta(meta);