import { acquireQvac, releaseQvac, loadAuxiliaryModel, qvacSdk, withQvacMaster, qvacBusy } from './qvac-master.js'; export class QvacPerception { constructor({ model = process.env.JARVIS_OCR_MODEL || 'OCR_LATIN' } = {}) { this.model = model; this.modelId = null; } async ocr(image) { if (qvacBusy()) throw new Error('OCR skipped while the language model is answering'); await acquireQvac(); try { this.modelId ||= await loadAuxiliaryModel(this.model, {}); const sdk = await qvacSdk(); const result = await withQvacMaster(() => sdk.ocr({ modelId: this.modelId, image, stream: false })); return result.blocks; } finally { releaseQvac(); } } }