@infersec/conduit 1.45.0 → 1.46.0
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 +56 -11
- package/dist/state/ConduitStateReportManager.d.ts +5 -1
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -18458,6 +18458,13 @@ preprocess(value => {
|
|
|
18458
18458
|
return value === 1;
|
|
18459
18459
|
return value;
|
|
18460
18460
|
}, boolean$1());
|
|
18461
|
+
preprocess(value => {
|
|
18462
|
+
if (typeof value === "number")
|
|
18463
|
+
return value;
|
|
18464
|
+
if (typeof value === "string" && /^-?\d+(\.\d+)?$/.test(value))
|
|
18465
|
+
return Number(value);
|
|
18466
|
+
return value;
|
|
18467
|
+
}, number$1());
|
|
18461
18468
|
_enum([
|
|
18462
18469
|
"DELETE",
|
|
18463
18470
|
"GET",
|
|
@@ -18874,6 +18881,7 @@ const InferenceAgentMachineGPUSchema = object({
|
|
|
18874
18881
|
driverVersion: string$1().nullable(),
|
|
18875
18882
|
memoryFreeBytes: number$1().int().nonnegative().nullable(),
|
|
18876
18883
|
memoryTotalBytes: number$1().int().nonnegative().nullable(),
|
|
18884
|
+
memoryUsedBytes: number$1().int().nonnegative().nullable(),
|
|
18877
18885
|
model: string$1().nullable(),
|
|
18878
18886
|
temperatureCelsius: number$1().nullable(),
|
|
18879
18887
|
vendor: string$1().nullable()
|
|
@@ -114706,16 +114714,19 @@ async function proxyRequest({ configuration, request, signal }) {
|
|
|
114706
114714
|
|
|
114707
114715
|
class ConduitStateReportManager {
|
|
114708
114716
|
apiClient;
|
|
114717
|
+
collectMachineMetadata;
|
|
114709
114718
|
conduitStateManager;
|
|
114710
114719
|
downloadProgressReportIntervalMs;
|
|
114711
114720
|
logger;
|
|
114712
114721
|
stateIntervalMs;
|
|
114713
114722
|
conduitStateReportInFlight = false;
|
|
114714
114723
|
lastConduitStateReportAt = 0;
|
|
114724
|
+
lastMachineReportAt = null;
|
|
114715
114725
|
pendingConduitStateReport = null;
|
|
114716
114726
|
stateInterval = null;
|
|
114717
|
-
constructor({ apiClient, conduitStateManager, downloadProgressReportIntervalMs, logger, stateIntervalMs }) {
|
|
114727
|
+
constructor({ apiClient, collectMachineMetadata, conduitStateManager, downloadProgressReportIntervalMs, logger, stateIntervalMs }) {
|
|
114718
114728
|
this.apiClient = apiClient;
|
|
114729
|
+
this.collectMachineMetadata = collectMachineMetadata;
|
|
114719
114730
|
this.conduitStateManager = conduitStateManager;
|
|
114720
114731
|
this.downloadProgressReportIntervalMs = downloadProgressReportIntervalMs;
|
|
114721
114732
|
this.logger = logger;
|
|
@@ -114777,6 +114788,19 @@ class ConduitStateReportManager {
|
|
|
114777
114788
|
error: asError(error)
|
|
114778
114789
|
});
|
|
114779
114790
|
}
|
|
114791
|
+
if (this.lastMachineReportAt === null ||
|
|
114792
|
+
Date.now() - this.lastMachineReportAt >= 30_000) {
|
|
114793
|
+
try {
|
|
114794
|
+
const machine = await this.collectMachineMetadata();
|
|
114795
|
+
await this.apiClient.reportMachineMetadata({ machine });
|
|
114796
|
+
this.lastMachineReportAt = Date.now();
|
|
114797
|
+
}
|
|
114798
|
+
catch (error) {
|
|
114799
|
+
this.logger.error("Failed to report machine metadata", {
|
|
114800
|
+
error: asError(error)
|
|
114801
|
+
});
|
|
114802
|
+
}
|
|
114803
|
+
}
|
|
114780
114804
|
}
|
|
114781
114805
|
catch (error) {
|
|
114782
114806
|
this.logger.error("Conduit state update failed", {
|
|
@@ -124005,13 +124029,25 @@ function resolveCpuValue(value) {
|
|
|
124005
124029
|
}
|
|
124006
124030
|
return null;
|
|
124007
124031
|
}
|
|
124032
|
+
function parseLspciFields(line) {
|
|
124033
|
+
if (line.includes("\t")) {
|
|
124034
|
+
return line.split("\t");
|
|
124035
|
+
}
|
|
124036
|
+
const fields = [];
|
|
124037
|
+
const re = /("[^"]*"|\S+)/g;
|
|
124038
|
+
let match;
|
|
124039
|
+
while ((match = re.exec(line)) !== null) {
|
|
124040
|
+
fields.push(match[1]);
|
|
124041
|
+
}
|
|
124042
|
+
return fields;
|
|
124043
|
+
}
|
|
124008
124044
|
async function detectGPUsViaLspci() {
|
|
124009
124045
|
try {
|
|
124010
124046
|
const { stdout } = await execa("lspci", ["-nn", "-mm", "-D"]);
|
|
124011
124047
|
const lines = stdout.split("\n");
|
|
124012
124048
|
const gpus = [];
|
|
124013
124049
|
for (const line of lines) {
|
|
124014
|
-
const fields = line
|
|
124050
|
+
const fields = parseLspciFields(line);
|
|
124015
124051
|
if (fields.length < 4)
|
|
124016
124052
|
continue;
|
|
124017
124053
|
const classField = stripQuotes(fields[1] ?? "");
|
|
@@ -124160,6 +124196,7 @@ function buildMergedGPUs(options) {
|
|
|
124160
124196
|
const validSysfsUsed = sysfsUsed !== null && Number.isFinite(sysfsUsed);
|
|
124161
124197
|
if (validSysfsTotal) {
|
|
124162
124198
|
existing.memoryTotalBytes = sysfsTotal;
|
|
124199
|
+
existing.memoryUsedBytes = validSysfsUsed ? sysfsUsed : null;
|
|
124163
124200
|
existing.memoryFreeBytes =
|
|
124164
124201
|
validSysfsUsed && sysfsUsed !== null ? sysfsTotal - sysfsUsed : null;
|
|
124165
124202
|
}
|
|
@@ -124183,6 +124220,7 @@ function buildMergedGPUs(options) {
|
|
|
124183
124220
|
? totalBytes - usedBytes
|
|
124184
124221
|
: null,
|
|
124185
124222
|
memoryTotalBytes: totalBytes,
|
|
124223
|
+
memoryUsedBytes: usedBytes !== null && Number.isFinite(usedBytes) ? usedBytes : null,
|
|
124186
124224
|
model: lspciGPU.model,
|
|
124187
124225
|
temperatureCelsius: null,
|
|
124188
124226
|
vendor: lspciGPU.vendor
|
|
@@ -124207,15 +124245,21 @@ async function collectMachineMetadata() {
|
|
|
124207
124245
|
: { controllers: [] };
|
|
124208
124246
|
const resolvedLspciGPUs = lspciGPUs.status === "fulfilled" ? lspciGPUs.value : [];
|
|
124209
124247
|
const resolvedRocmVRAM = rocmVRAM.status === "fulfilled" ? rocmVRAM.value : [];
|
|
124210
|
-
const siGPUs = (graphicsInfo.controllers ?? []).map((controller) =>
|
|
124211
|
-
|
|
124212
|
-
|
|
124213
|
-
|
|
124214
|
-
|
|
124215
|
-
|
|
124216
|
-
|
|
124217
|
-
|
|
124218
|
-
|
|
124248
|
+
const siGPUs = (graphicsInfo.controllers ?? []).map((controller) => {
|
|
124249
|
+
const totalBytes = normalizeMegabytes(controller.memoryTotal ?? null);
|
|
124250
|
+
const freeBytes = normalizeMegabytes(controller.memoryFree ?? null);
|
|
124251
|
+
const usedBytes = totalBytes !== null && freeBytes !== null ? totalBytes - freeBytes : null;
|
|
124252
|
+
return {
|
|
124253
|
+
bus: controller.bus ?? null,
|
|
124254
|
+
driverVersion: controller.driverVersion ?? null,
|
|
124255
|
+
memoryFreeBytes: freeBytes,
|
|
124256
|
+
memoryTotalBytes: totalBytes,
|
|
124257
|
+
memoryUsedBytes: usedBytes !== null && usedBytes >= 0 ? usedBytes : null,
|
|
124258
|
+
model: controller.model ?? controller.name ?? null,
|
|
124259
|
+
temperatureCelsius: controller.temperatureGpu ?? null,
|
|
124260
|
+
vendor: controller.vendor ?? null
|
|
124261
|
+
};
|
|
124262
|
+
});
|
|
124219
124263
|
const busSources = new Set();
|
|
124220
124264
|
for (const lspciGPU of resolvedLspciGPUs) {
|
|
124221
124265
|
busSources.add(lspciGPU.bus);
|
|
@@ -124319,6 +124363,7 @@ async function createApplication({ abortController, apiClient, configuration, lo
|
|
|
124319
124363
|
});
|
|
124320
124364
|
const conduitStateReportManager = new ConduitStateReportManager({
|
|
124321
124365
|
apiClient,
|
|
124366
|
+
collectMachineMetadata: collectMachineMetadata,
|
|
124322
124367
|
conduitStateManager,
|
|
124323
124368
|
downloadProgressReportIntervalMs: 5000,
|
|
124324
124369
|
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;
|