feat: stabilize HarborForge monitor sidecar plugin #2

Merged
hzhang merged 10 commits from feat/telemetry-sidecar-v2 into main 2026-03-20 09:18:37 +00:00
Showing only changes of commit 8ebc76931f - Show all commits

View File

@@ -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;
}