diff --git a/src/compat.ts b/src/compat.ts index 2d4934c..d66cca4 100644 --- a/src/compat.ts +++ b/src/compat.ts @@ -51,10 +51,17 @@ export function isHostVersionSupported(hostVersion: string): boolean { return compareVersions(host, min) >= 0; } +/** Tracks host versions that have already passed the compatibility check. */ +const checkedHostVersions = new Set(); + /** * Fail-fast guard. Call at the very start of `register()` to prevent the * plugin from loading on an incompatible host. * + * On the first successful check the result is logged at `info` level. + * Subsequent re-entrant calls for the same version are logged at `debug` + * to avoid log spam when the host invokes `register()` multiple times. + * * @throws {Error} with a human-readable message when the host is out of range. */ export function assertHostCompatibility(hostVersion: string | undefined): void { @@ -65,7 +72,12 @@ export function assertHostCompatibility(hostVersion: string | undefined): void { return; } if (isHostVersionSupported(hostVersion)) { - logger.info(`[compat] Host OpenClaw ${hostVersion} >= ${SUPPORTED_HOST_MIN}, OK.`); + if (checkedHostVersions.has(hostVersion)) { + logger.debug(`[compat] Host OpenClaw ${hostVersion} >= ${SUPPORTED_HOST_MIN}, OK (already verified).`); + } else { + checkedHostVersions.add(hostVersion); + logger.info(`[compat] Host OpenClaw ${hostVersion} >= ${SUPPORTED_HOST_MIN}, OK.`); + } return; } throw new Error( diff --git a/src/runtime.ts b/src/runtime.ts index bbe1a90..f4ed43e 100644 --- a/src/runtime.ts +++ b/src/runtime.ts @@ -3,15 +3,25 @@ import type { PluginRuntime } from "openclaw/plugin-sdk/core"; import { logger } from "./util/logger.js"; let pluginRuntime: PluginRuntime | null = null; +let runtimeInitialized = false; export type PluginChannelRuntime = PluginRuntime["channel"]; /** * Sets the global Weixin runtime (called from plugin register). + * + * The first successful call is logged at `info` level. Subsequent + * re-entrant calls (caused by the host re-invoking `register()`) are + * logged at `debug` to keep log output clean. */ export function setWeixinRuntime(next: PluginRuntime): void { pluginRuntime = next; - logger.info(`[runtime] setWeixinRuntime called, runtime set successfully`); + if (runtimeInitialized) { + logger.debug(`[runtime] setWeixinRuntime called (re-entrant), runtime updated`); + } else { + runtimeInitialized = true; + logger.info(`[runtime] setWeixinRuntime called, runtime set successfully`); + } } /**