@infersec/conduit 1.44.0 → 1.45.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.js +49 -11
- package/dist/state/ConduitStateReportManager.d.ts +5 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -18874,6 +18874,7 @@ const InferenceAgentMachineGPUSchema = object({
|
|
|
18874
18874
|
driverVersion: string$1().nullable(),
|
|
18875
18875
|
memoryFreeBytes: number$1().int().nonnegative().nullable(),
|
|
18876
18876
|
memoryTotalBytes: number$1().int().nonnegative().nullable(),
|
|
18877
|
+
memoryUsedBytes: number$1().int().nonnegative().nullable(),
|
|
18877
18878
|
model: string$1().nullable(),
|
|
18878
18879
|
temperatureCelsius: number$1().nullable(),
|
|
18879
18880
|
vendor: string$1().nullable()
|
|
@@ -114706,16 +114707,19 @@ async function proxyRequest({ configuration, request, signal }) {
|
|
|
114706
114707
|
|
|
114707
114708
|
class ConduitStateReportManager {
|
|
114708
114709
|
apiClient;
|
|
114710
|
+
collectMachineMetadata;
|
|
114709
114711
|
conduitStateManager;
|
|
114710
114712
|
downloadProgressReportIntervalMs;
|
|
114711
114713
|
logger;
|
|
114712
114714
|
stateIntervalMs;
|
|
114713
114715
|
conduitStateReportInFlight = false;
|
|
114714
114716
|
lastConduitStateReportAt = 0;
|
|
114717
|
+
lastMachineReportAt = null;
|
|
114715
114718
|
pendingConduitStateReport = null;
|
|
114716
114719
|
stateInterval = null;
|
|
114717
|
-
constructor({ apiClient, conduitStateManager, downloadProgressReportIntervalMs, logger, stateIntervalMs }) {
|
|
114720
|
+
constructor({ apiClient, collectMachineMetadata, conduitStateManager, downloadProgressReportIntervalMs, logger, stateIntervalMs }) {
|
|
114718
114721
|
this.apiClient = apiClient;
|
|
114722
|
+
this.collectMachineMetadata = collectMachineMetadata;
|
|
114719
114723
|
this.conduitStateManager = conduitStateManager;
|
|
114720
114724
|
this.downloadProgressReportIntervalMs = downloadProgressReportIntervalMs;
|
|
114721
114725
|
this.logger = logger;
|
|
@@ -114777,6 +114781,19 @@ class ConduitStateReportManager {
|
|
|
114777
114781
|
error: asError(error)
|
|
114778
114782
|
});
|
|
114779
114783
|
}
|
|
114784
|
+
if (this.lastMachineReportAt === null ||
|
|
114785
|
+
Date.now() - this.lastMachineReportAt >= 30_000) {
|
|
114786
|
+
try {
|
|
114787
|
+
const machine = await this.collectMachineMetadata();
|
|
114788
|
+
await this.apiClient.reportMachineMetadata({ machine });
|
|
114789
|
+
this.lastMachineReportAt = Date.now();
|
|
114790
|
+
}
|
|
114791
|
+
catch (error) {
|
|
114792
|
+
this.logger.error("Failed to report machine metadata", {
|
|
114793
|
+
error: asError(error)
|
|
114794
|
+
});
|
|
114795
|
+
}
|
|
114796
|
+
}
|
|
114780
114797
|
}
|
|
114781
114798
|
catch (error) {
|
|
114782
114799
|
this.logger.error("Conduit state update failed", {
|
|
@@ -124005,13 +124022,25 @@ function resolveCpuValue(value) {
|
|
|
124005
124022
|
}
|
|
124006
124023
|
return null;
|
|
124007
124024
|
}
|
|
124025
|
+
function parseLspciFields(line) {
|
|
124026
|
+
if (line.includes("\t")) {
|
|
124027
|
+
return line.split("\t");
|
|
124028
|
+
}
|
|
124029
|
+
const fields = [];
|
|
124030
|
+
const re = /("[^"]*"|\S+)/g;
|
|
124031
|
+
let match;
|
|
124032
|
+
while ((match = re.exec(line)) !== null) {
|
|
124033
|
+
fields.push(match[1]);
|
|
124034
|
+
}
|
|
124035
|
+
return fields;
|
|
124036
|
+
}
|
|
124008
124037
|
async function detectGPUsViaLspci() {
|
|
124009
124038
|
try {
|
|
124010
124039
|
const { stdout } = await execa("lspci", ["-nn", "-mm", "-D"]);
|
|
124011
124040
|
const lines = stdout.split("\n");
|
|
124012
124041
|
const gpus = [];
|
|
124013
124042
|
for (const line of lines) {
|
|
124014
|
-
const fields = line
|
|
124043
|
+
const fields = parseLspciFields(line);
|
|
124015
124044
|
if (fields.length < 4)
|
|
124016
124045
|
continue;
|
|
124017
124046
|
const classField = stripQuotes(fields[1] ?? "");
|
|
@@ -124160,6 +124189,7 @@ function buildMergedGPUs(options) {
|
|
|
124160
124189
|
const validSysfsUsed = sysfsUsed !== null && Number.isFinite(sysfsUsed);
|
|
124161
124190
|
if (validSysfsTotal) {
|
|
124162
124191
|
existing.memoryTotalBytes = sysfsTotal;
|
|
124192
|
+
existing.memoryUsedBytes = validSysfsUsed ? sysfsUsed : null;
|
|
124163
124193
|
existing.memoryFreeBytes =
|
|
124164
124194
|
validSysfsUsed && sysfsUsed !== null ? sysfsTotal - sysfsUsed : null;
|
|
124165
124195
|
}
|
|
@@ -124183,6 +124213,7 @@ function buildMergedGPUs(options) {
|
|
|
124183
124213
|
? totalBytes - usedBytes
|
|
124184
124214
|
: null,
|
|
124185
124215
|
memoryTotalBytes: totalBytes,
|
|
124216
|
+
memoryUsedBytes: usedBytes !== null && Number.isFinite(usedBytes) ? usedBytes : null,
|
|
124186
124217
|
model: lspciGPU.model,
|
|
124187
124218
|
temperatureCelsius: null,
|
|
124188
124219
|
vendor: lspciGPU.vendor
|
|
@@ -124207,15 +124238,21 @@ async function collectMachineMetadata() {
|
|
|
124207
124238
|
: { controllers: [] };
|
|
124208
124239
|
const resolvedLspciGPUs = lspciGPUs.status === "fulfilled" ? lspciGPUs.value : [];
|
|
124209
124240
|
const resolvedRocmVRAM = rocmVRAM.status === "fulfilled" ? rocmVRAM.value : [];
|
|
124210
|
-
const siGPUs = (graphicsInfo.controllers ?? []).map((controller) =>
|
|
124211
|
-
|
|
124212
|
-
|
|
124213
|
-
|
|
124214
|
-
|
|
124215
|
-
|
|
124216
|
-
|
|
124217
|
-
|
|
124218
|
-
|
|
124241
|
+
const siGPUs = (graphicsInfo.controllers ?? []).map((controller) => {
|
|
124242
|
+
const totalBytes = normalizeMegabytes(controller.memoryTotal ?? null);
|
|
124243
|
+
const freeBytes = normalizeMegabytes(controller.memoryFree ?? null);
|
|
124244
|
+
const usedBytes = totalBytes !== null && freeBytes !== null ? totalBytes - freeBytes : null;
|
|
124245
|
+
return {
|
|
124246
|
+
bus: controller.bus ?? null,
|
|
124247
|
+
driverVersion: controller.driverVersion ?? null,
|
|
124248
|
+
memoryFreeBytes: freeBytes,
|
|
124249
|
+
memoryTotalBytes: totalBytes,
|
|
124250
|
+
memoryUsedBytes: usedBytes !== null && usedBytes >= 0 ? usedBytes : null,
|
|
124251
|
+
model: controller.model ?? controller.name ?? null,
|
|
124252
|
+
temperatureCelsius: controller.temperatureGpu ?? null,
|
|
124253
|
+
vendor: controller.vendor ?? null
|
|
124254
|
+
};
|
|
124255
|
+
});
|
|
124219
124256
|
const busSources = new Set();
|
|
124220
124257
|
for (const lspciGPU of resolvedLspciGPUs) {
|
|
124221
124258
|
busSources.add(lspciGPU.bus);
|
|
@@ -124319,6 +124356,7 @@ async function createApplication({ abortController, apiClient, configuration, lo
|
|
|
124319
124356
|
});
|
|
124320
124357
|
const conduitStateReportManager = new ConduitStateReportManager({
|
|
124321
124358
|
apiClient,
|
|
124359
|
+
collectMachineMetadata: collectMachineMetadata,
|
|
124322
124360
|
conduitStateManager,
|
|
124323
124361
|
downloadProgressReportIntervalMs: 5000,
|
|
124324
124362
|
logger,
|
|
@@ -1,18 +1,22 @@
|
|
|
1
|
+
import type { InferenceAgentMachineMetadata } from "@infersec/definitions";
|
|
1
2
|
import { Logger } from "@infersec/logger";
|
|
2
3
|
import { APIClient } from "../apiClient/index.js";
|
|
3
4
|
import { ConduitStateManager } from "./ConduitStateManager.js";
|
|
4
5
|
export declare class ConduitStateReportManager {
|
|
5
6
|
private apiClient;
|
|
7
|
+
private collectMachineMetadata;
|
|
6
8
|
private conduitStateManager;
|
|
7
9
|
private downloadProgressReportIntervalMs;
|
|
8
10
|
private logger;
|
|
9
11
|
private stateIntervalMs;
|
|
10
12
|
private conduitStateReportInFlight;
|
|
11
13
|
private lastConduitStateReportAt;
|
|
14
|
+
private lastMachineReportAt;
|
|
12
15
|
private pendingConduitStateReport;
|
|
13
16
|
private stateInterval;
|
|
14
|
-
constructor({ apiClient, conduitStateManager, downloadProgressReportIntervalMs, logger, stateIntervalMs }: {
|
|
17
|
+
constructor({ apiClient, collectMachineMetadata, conduitStateManager, downloadProgressReportIntervalMs, logger, stateIntervalMs }: {
|
|
15
18
|
apiClient: APIClient;
|
|
19
|
+
collectMachineMetadata: () => Promise<InferenceAgentMachineMetadata>;
|
|
16
20
|
conduitStateManager: ConduitStateManager;
|
|
17
21
|
downloadProgressReportIntervalMs: number;
|
|
18
22
|
logger: Logger;
|