@infersec/conduit 1.7.0 → 1.8.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 CHANGED
@@ -6,7 +6,7 @@ const __dirname = __pathDirname(__filename);
6
6
 
7
7
  import { parseArgs } from 'node:util';
8
8
  import 'node:crypto';
9
- import { a as asError, s as startInferenceAgent } from './start-BF-CnHXg.js';
9
+ import { a as asError, s as startInferenceAgent } from './start-ItMOqpI1.js';
10
10
  import 'argon2';
11
11
  import 'node:child_process';
12
12
  import 'node:stream';
package/dist/index.js CHANGED
@@ -5,7 +5,7 @@ const __filename = __fileURLToPath(import.meta.url);
5
5
  const __dirname = __pathDirname(__filename);
6
6
 
7
7
  import 'node:crypto';
8
- import { s as startInferenceAgent, a as asError } from './start-BF-CnHXg.js';
8
+ import { s as startInferenceAgent, a as asError } from './start-ItMOqpI1.js';
9
9
  import 'argon2';
10
10
  import 'node:child_process';
11
11
  import 'node:stream';
@@ -30,5 +30,7 @@ export declare class ModelManager extends EventEmitter<ModelManagerEvents> {
30
30
  onDownloadProgress?: (update: ModelDownloadProgressUpdate) => void;
31
31
  }): Promise<void>;
32
32
  start(): Promise<void>;
33
+ private isEngineReady;
34
+ private waitForEngineReady;
33
35
  }
34
36
  export {};
@@ -104881,8 +104881,9 @@ const glob = Object.assign(glob_, {
104881
104881
  });
104882
104882
  glob.glob = glob;
104883
104883
 
104884
+ const DEFAULT_LLAMACPP_GPU_LAYERS = 999;
104884
104885
  const LLAMACPP_START_ARGS = ["--host", "0.0.0.0", "--port", "8000", "--jinja"];
104885
- const LLAMACPP_EXECUTABLE = "llama-server";
104886
+ const LLAMACPP_EXECUTABLE = process.env.LLAMACPP_EXECUTABLE ?? "llama-server";
104886
104887
  const DEFAULT_LLAMACPP_CONTEXT_LENGTH = 131072;
104887
104888
  async function findQuantizedModelTarget({ model, path }) {
104888
104889
  if (model.source.type === "storage") {
@@ -104918,6 +104919,10 @@ async function startLlamacpp({ targetDirectory }) {
104918
104919
  const contextLength = Math.max(1, this.contextLength ?? DEFAULT_LLAMACPP_CONTEXT_LENGTH);
104919
104920
  const parallelism = this.parallelism;
104920
104921
  const args = [...LLAMACPP_START_ARGS, "--model", target, "--ctx-size", String(contextLength)];
104922
+ const gpuLayers = Number.parseInt(process.env.LLAMACPP_GPU_LAYERS ?? String(DEFAULT_LLAMACPP_GPU_LAYERS), 10);
104923
+ if (Number.isFinite(gpuLayers) && gpuLayers > 0) {
104924
+ args.push("--n-gpu-layers", String(gpuLayers));
104925
+ }
104921
104926
  if (typeof parallelism === "number") {
104922
104927
  args.push("--parallel", String(Math.max(1, parallelism)));
104923
104928
  }
@@ -105086,8 +105091,48 @@ class ModelManager extends EventEmitter {
105086
105091
  this.logger.info("Started LLM engine", {
105087
105092
  agentEngineType: this.engine
105088
105093
  });
105094
+ try {
105095
+ await this.waitForEngineReady();
105096
+ }
105097
+ catch (error) {
105098
+ const err = error instanceof Error ? error : new Error(String(error));
105099
+ this.emit("engineError", err);
105100
+ throw err;
105101
+ }
105089
105102
  this.emit("engineReady");
105090
105103
  }
105104
+ async isEngineReady() {
105105
+ switch (this.engine) {
105106
+ case "llama.cpp":
105107
+ case "vllm": {
105108
+ try {
105109
+ const response = await this.fetchOpenAI("/v1/models", {
105110
+ method: "GET",
105111
+ signal: AbortSignal.timeout(5000)
105112
+ });
105113
+ return response.ok;
105114
+ }
105115
+ catch (_error) {
105116
+ return false;
105117
+ }
105118
+ }
105119
+ default:
105120
+ return true;
105121
+ }
105122
+ }
105123
+ async waitForEngineReady() {
105124
+ const maxWaitMs = 5 * 60 * 1000;
105125
+ const pollIntervalMs = 2000;
105126
+ const start = Date.now();
105127
+ while (Date.now() - start < maxWaitMs) {
105128
+ const ready = await this.isEngineReady();
105129
+ if (ready) {
105130
+ return;
105131
+ }
105132
+ await new Promise(resolve => setTimeout(resolve, pollIntervalMs));
105133
+ }
105134
+ throw new Error("LLM engine failed readiness checks within timeout");
105135
+ }
105091
105136
  }
105092
105137
 
105093
105138
  async function handleSSERequests({ apiURL, configuration, logger, onRequest, onRequestEnd, onRequestStart }) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@infersec/conduit",
3
3
  "description": "End user conduit agent for connecting local LLMs to the cloud.",
4
- "version": "1.7.0",
4
+ "version": "1.8.1",
5
5
  "bin": {
6
6
  "infersec-conduit": "./dist/cli.js"
7
7
  },