From d1f339170e053f62497e86f2ed23756584dbbeef Mon Sep 17 00:00:00 2001 From: Raven Scott Date: Fri, 11 Sep 2026 15:00:17 -0400 Subject: [PATCH] R2 --- daemon/qvac-master.js | 16 +++++++++++++++- daemon/voice-adapters.js | 10 ++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/daemon/qvac-master.js b/daemon/qvac-master.js index f5869d3..d9b6d81 100644 --- a/daemon/qvac-master.js +++ b/daemon/qvac-master.js @@ -1,4 +1,5 @@ import { createRequire } from 'node:module'; +import fs from 'node:fs'; import path from 'node:path'; const harnessPath = process.env.JARVIS_HARNESS_PATH || path.resolve(new URL('../vendor/agent-harness', import.meta.url).pathname); @@ -18,8 +19,21 @@ export const QVAC_MASTER = Object.freeze({ gpuLayers: 99, }); +export function sdkPackagePath() { + // Package exports intentionally block @qvac/sdk/package.json in current + // releases, so resolve the version file from the two supported install + // layouts instead of requiring an exported subpath. + const candidates = [ + path.join(harnessPath, 'node_modules/@qvac/sdk/package.json'), + path.resolve(harnessPath, '../../node_modules/@qvac/sdk/package.json'), + path.resolve(new URL('../node_modules/@qvac/sdk/package.json', import.meta.url).pathname), + ]; + for (const candidate of candidates) if (fs.existsSync(candidate)) return candidate; + throw new Error(`Jarvis could not resolve @qvac/sdk from the harness or repository; checked ${candidates.join(', ')}`); +} + export function assertSdkVersion() { - const sdkPackage = require(path.join(harnessPath, 'node_modules/@qvac/sdk/package.json')); + const sdkPackage = require(sdkPackagePath()); if (!/^0\.19\./.test(sdkPackage.version)) { throw new Error(`Jarvis requires vendored @qvac/sdk in the 0.19.x series; found ${sdkPackage.version}`); } diff --git a/daemon/voice-adapters.js b/daemon/voice-adapters.js index cb7c0b7..c424d90 100644 --- a/daemon/voice-adapters.js +++ b/daemon/voice-adapters.js @@ -1,11 +1,5 @@ -import { createRequire } from 'node:module'; import { EventEmitter } from 'node:events'; -import path from 'node:path'; -import { acquireQvac, releaseQvac, loadAuxiliaryModel, unloadAuxiliaryModel, qvacSdk, withQvacMaster } from './qvac-master.js'; - -const require = createRequire(import.meta.url); -const harnessPath = process.env.JARVIS_HARNESS_PATH || path.resolve(new URL('../vendor/agent-harness', import.meta.url).pathname); -const sdkPackage = require(path.join(harnessPath, 'node_modules/@qvac/sdk/package.json')); +import { acquireQvac, releaseQvac, loadAuxiliaryModel, unloadAuxiliaryModel, qvacSdk, withQvacMaster, assertSdkVersion } from './qvac-master.js'; export class QvacVoiceAdapter extends EventEmitter { constructor({ asrModel = process.env.JARVIS_ASR_MODEL || 'WHISPER_TINY', ttsModel = process.env.JARVIS_TTS_MODEL || 'TTS_EN_SUPERTONIC_Q8_0' } = {}) { @@ -14,7 +8,7 @@ export class QvacVoiceAdapter extends EventEmitter { async start() { if (this.acquired) return; - if (!/^0\.19\./.test(sdkPackage.version)) throw new Error(`Jarvis voice adapter requires QVAC 0.19.x; found ${sdkPackage.version}`); + assertSdkVersion(); await acquireQvac(); this.acquired = true; try { this.asrId = await loadAuxiliaryModel(this.asrModel, { vadModelSrc: 'VAD_SILERO_5_1_2', audio_format: 's16le', language: 'en', no_timestamps: true, vad_params: { threshold: 0.6, min_speech_duration_ms: 300, min_silence_duration_ms: 700, max_speech_duration_s: 15, speech_pad_ms: 200 } });