feat: stabilize HarborForge monitor sidecar plugin #2
@@ -17,6 +17,11 @@ interface PluginConfig {
|
||||
logLevel?: 'debug' | 'info' | 'warn' | 'error';
|
||||
}
|
||||
|
||||
interface PluginEntryLike {
|
||||
enabled?: boolean;
|
||||
config?: PluginConfig;
|
||||
}
|
||||
|
||||
interface PluginAPI {
|
||||
logger: {
|
||||
info: (...args: any[]) => void;
|
||||
@@ -30,7 +35,7 @@ interface PluginAPI {
|
||||
registerTool: (factory: (ctx: any) => any) => void;
|
||||
}
|
||||
|
||||
export default function register(api: PluginAPI, config: PluginConfig) {
|
||||
export default function register(api: PluginAPI, rawConfig: PluginConfig | PluginEntryLike | undefined) {
|
||||
const logger = api.logger || {
|
||||
info: (...args: any[]) => console.log('[HF-Monitor]', ...args),
|
||||
error: (...args: any[]) => console.error('[HF-Monitor]', ...args),
|
||||
@@ -38,7 +43,24 @@ export default function register(api: PluginAPI, config: PluginConfig) {
|
||||
warn: (...args: any[]) => console.warn('[HF-Monitor]', ...args),
|
||||
};
|
||||
|
||||
if (!config?.enabled) {
|
||||
const entryLike = rawConfig as PluginEntryLike | undefined;
|
||||
const config: PluginConfig = entryLike?.config
|
||||
? {
|
||||
...entryLike.config,
|
||||
enabled: entryLike.config.enabled ?? entryLike.enabled,
|
||||
}
|
||||
: ((rawConfig as PluginConfig | undefined) ?? {});
|
||||
|
||||
const enabled = config.enabled !== false;
|
||||
|
||||
logger.info('HarborForge Monitor plugin config resolved', {
|
||||
enabled,
|
||||
hasApiKey: Boolean(config.apiKey),
|
||||
backendUrl: config.backendUrl ?? null,
|
||||
identifier: config.identifier ?? null,
|
||||
});
|
||||
|
||||
if (!enabled) {
|
||||
logger.info('HarborForge Monitor plugin disabled');
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user