scripts / verify-primer.cjs
const assert = require('node:assert/strict');
const { LMStudioClient } = require('@lmstudio/sdk');
const { ensureVisionModel, PRIMER_ID, PRIMER_MODEL } = require('../dist/visionPrimer');
(async () => {
const client = new LMStudioClient();
const before = await Promise.all((await client.llm.listLoaded()).map(model => model.getModelInfo()));
if (before.some(info => info.identifier === PRIMER_ID)) await client.llm.unload(PRIMER_ID);
// Exercise the real SDK cold-load while preserving the user's manual instance.
const coldClient = {
system: client.system,
llm: { listLoaded: async () => [], load: client.llm.load.bind(client.llm) },
};
try {
assert.equal(await ensureVisionModel(coldClient), PRIMER_ID);
const loaded = await Promise.all((await client.llm.listLoaded()).map(model => model.getModelInfo()));
const helper = loaded.find(info => info.identifier === PRIMER_ID);
assert.equal(helper.path, PRIMER_MODEL);
assert.equal(helper.contextLength, 512);
assert.equal(helper.vision, true);
console.log('Real SDK cold-load passed: vision=true, contextLength=512, CPU requested, no TTL requested.');
if (before.some(info => info.path === PRIMER_MODEL && info.identifier !== PRIMER_ID)) {
await client.llm.unload(PRIMER_ID);
const reused = await ensureVisionModel(client);
assert.notEqual(reused, PRIMER_ID);
console.log('Manual helper reused; dedicated duplicate unloaded.');
}
} catch (error) { throw error; }
})().then(() => process.exit(0), error => { console.error(error.message); process.exit(1); });
scripts / verify-primer.cjs
const assert = require('node:assert/strict');
const { LMStudioClient } = require('@lmstudio/sdk');
const { ensureVisionModel, PRIMER_ID, PRIMER_MODEL } = require('../dist/visionPrimer');
(async () => {
const client = new LMStudioClient();
const before = await Promise.all((await client.llm.listLoaded()).map(model => model.getModelInfo()));
if (before.some(info => info.identifier === PRIMER_ID)) await client.llm.unload(PRIMER_ID);
// Exercise the real SDK cold-load while preserving the user's manual instance.
const coldClient = {
system: client.system,
llm: { listLoaded: async () => [], load: client.llm.load.bind(client.llm) },
};
try {
assert.equal(await ensureVisionModel(coldClient), PRIMER_ID);
const loaded = await Promise.all((await client.llm.listLoaded()).map(model => model.getModelInfo()));
const helper = loaded.find(info => info.identifier === PRIMER_ID);
assert.equal(helper.path, PRIMER_MODEL);
assert.equal(helper.contextLength, 512);
assert.equal(helper.vision, true);
console.log('Real SDK cold-load passed: vision=true, contextLength=512, CPU requested, no TTL requested.');
if (before.some(info => info.path === PRIMER_MODEL && info.identifier !== PRIMER_ID)) {
await client.llm.unload(PRIMER_ID);
const reused = await ensureVisionModel(client);
assert.notEqual(reused, PRIMER_ID);
console.log('Manual helper reused; dedicated duplicate unloaded.');
}
} catch (error) { throw error; }
})().then(() => process.exit(0), error => { console.error(error.message); process.exit(1); });