Integrate plugin with local monitor bridge

This commit is contained in:
zhi
2026-03-21 16:07:01 +00:00
parent 9f649e2b39
commit 78a61e0fb2
12 changed files with 225 additions and 5 deletions

View File

@@ -0,0 +1,44 @@
"use strict";
/**
* Monitor Bridge Client
*
* Queries the local HarborForge.Monitor bridge endpoint on MONITOR_PORT
* to enrich plugin telemetry with host/hardware data.
*
* If the bridge is unreachable, all methods return null gracefully —
* the plugin continues to function without Monitor data.
*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.MonitorBridgeClient = void 0;
class MonitorBridgeClient {
baseUrl;
timeoutMs;
constructor(port, timeoutMs = 3000) {
this.baseUrl = `http://127.0.0.1:${port}`;
this.timeoutMs = timeoutMs;
}
async health() {
return this.fetchJson('/health');
}
async telemetry() {
return this.fetchJson('/telemetry');
}
async fetchJson(path) {
try {
const controller = new AbortController();
const timeout = setTimeout(() => controller.abort(), this.timeoutMs);
const response = await fetch(`${this.baseUrl}${path}`, {
signal: controller.signal,
});
clearTimeout(timeout);
if (!response.ok)
return null;
return (await response.json());
}
catch {
return null;
}
}
}
exports.MonitorBridgeClient = MonitorBridgeClient;
//# sourceMappingURL=monitor-bridge.js.map