63 lines
2.7 KiB
JavaScript
63 lines
2.7 KiB
JavaScript
const {test}=require('node:test');
|
|
const assert=require('node:assert/strict');
|
|
const {routeBrain}=require('../.test-build/llm/index.js');
|
|
const {seed}=require('../.test-build/seed.js');
|
|
|
|
test('Qwen3.5 4B is the default configured local brain',()=>{
|
|
const state=seed();
|
|
assert.equal(state.settings.model,'qwen3.5:4b');
|
|
assert.equal(state.settings.brains.residentModel,'qwen3.5:4b');
|
|
assert.equal(state.settings.brains.heroModel,'qwen3.5:4b');
|
|
});
|
|
|
|
test('Zaku receives the hero brain budget',()=>{
|
|
const state=seed();
|
|
state.settings.provider='ollama';
|
|
const zaku=state.bots.find(b=>b.id==='hero-zaku');
|
|
const route=routeBrain(zaku,state.settings);
|
|
assert.equal(route.provider,'ollama');
|
|
assert.equal(route.model,'qwen3.5:4b');
|
|
assert.equal(route.memoryLimit,state.settings.brains.heroMemoryLimit);
|
|
assert.equal(route.maxTokens,state.settings.brains.heroMaxTokens);
|
|
assert.match(route.reason,/Hero/);
|
|
});
|
|
|
|
test('background residents use deterministic utility brain by default',()=>{
|
|
const state=seed();
|
|
state.settings.provider='ollama';
|
|
const resident=state.bots.find(b=>b.tier==='resident'&&b.simulationBand==='background');
|
|
const route=routeBrain(resident,state.settings);
|
|
assert.equal(route.provider,'deterministic');
|
|
assert.match(route.reason,/Background/);
|
|
});
|
|
|
|
test('foreground residents use configured local model',()=>{
|
|
const state=seed();
|
|
state.settings.provider='ollama';
|
|
const resident=state.bots.find(b=>b.tier==='resident');
|
|
resident.simulationBand='foreground';
|
|
const route=routeBrain(resident,state.settings);
|
|
assert.equal(route.provider,'ollama');
|
|
assert.equal(route.model,state.settings.brains.residentModel);
|
|
});
|
|
|
|
const {DeterministicProvider,LocalLLMProvider}=require('../.test-build/llm/index.js');
|
|
test('fresh injury overrides aggressive goals in both brain providers without a model call',async()=>{
|
|
const bot=seed().bots[0];
|
|
bot.personality.activities=['quest','rest'];bot.personality.aggression=100;
|
|
bot.world={at:Date.now()/1000,healthPct:70};
|
|
const observation={availableActions:['quest','rest']};
|
|
for(const provider of [new DeterministicProvider(),new LocalLLMProvider('ollama','unused',{})]){
|
|
const decision=await provider.decide(bot,observation);
|
|
assert.equal(decision.action,'rest');assert.match(decision.reason,/Staying alive/);
|
|
}
|
|
});
|
|
test('stale injury and unavailable rest do not override permitted decisions',async()=>{
|
|
const bot=seed().bots[0];bot.personality.activities=['quest','rest'];bot.personality.aggression=100;
|
|
bot.world={at:Date.now()/1000-120,healthPct:70};
|
|
const provider=new DeterministicProvider();
|
|
assert.equal((await provider.decide(bot,{availableActions:['quest','rest']})).action,'quest');
|
|
bot.world.at=Date.now()/1000;
|
|
assert.equal((await provider.decide(bot,{availableActions:['quest']})).action,'quest');
|
|
});
|