- Mirror dirigent plugin registration pattern - Read base config from api.pluginConfig - Read live config from api.config.plugins.entries.harborforge-monitor.config - Support gateway_start/gateway_stop lifecycle only - Compile nested plugin/core files
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
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 function getLivePluginConfig(
|
|
api: OpenClawPluginApiLike,
|
|
fallback: HarborForgeMonitorConfig
|
|
): HarborForgeMonitorConfig {
|
|
const root = (api.config as Record<string, unknown>) || {};
|
|
const plugins = (root.plugins as Record<string, unknown>) || {};
|
|
const entries = (plugins.entries as Record<string, unknown>) || {};
|
|
const entry = (entries['harborforge-monitor'] as Record<string, unknown>) || {};
|
|
const cfg = (entry.config as Record<string, unknown>) || {};
|
|
|
|
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,
|
|
} as HarborForgeMonitorConfig;
|
|
}
|
|
|
|
return fallback;
|
|
}
|