Files
HarborForge.OpenclawPlugin/plugin/core/live-config.ts

41 lines
1.2 KiB
TypeScript

export interface HarborForgeMonitorConfig {
enabled?: boolean;
backendUrl?: string;
identifier?: string;
apiKey?: string;
monitorPort?: number;
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['harbor-forge'] 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;
}