Route dashboard settings and decisions through the Classic connector
Core tests / core (push) Successful in 27s

This commit is contained in:
Codex
2026-09-25 18:32:31 -07:00
parent 3019acb9c1
commit f91724ebfa
6 changed files with 27 additions and 7 deletions
+20 -1
View File
@@ -1,4 +1,7 @@
import { z } from 'zod';
import {classicCommand} from '../classic';
import {queueAleCommand} from '../ale-store';
import {runGM} from '../gm';
import type { GameConnector,Bot,Decision,RuntimeConfig } from '../types';
const deathSignal=z.object({
@@ -45,5 +48,21 @@ export class AzerothCoreConnector implements GameConnector {
async decide(bot:Bot,decision:Decision,requestId:string){return z.object({accepted:z.literal(true),summary:z.string().max(1000),zone:z.string().max(120).optional()}).parse(await this.request(`/bots/${encodeURIComponent(bot.id)}/intent`,{decision,requestId}));}
}
export class ClassicConnector implements GameConnector {
id='cmangos-classic';
constructor(private config:RuntimeConfig){}
async health(){const result=await runGM('server info',true,true,this.config);return {ok:true,detail:result.output};}
async observe(bot:Bot){
if(!bot.world||Date.now()/1000-bot.world.at>30)throw new Error('Fresh Classic observation required');
return {zone:bot.zone,level:bot.level,alive:!bot.world.isDead&&!bot.world.isGhost,availableActions:bot.personality.activities,summary:JSON.stringify({zone:bot.zone,level:bot.level,health:bot.world.healthPct,mana:bot.world.manaPct,quests:bot.world.quests,combat:bot.world.inCombat,party:bot.world.groupNames})};
}
async lifecycle(){throw new Error('Classic maintains the fixed 50-character roster automatically. Manual lifecycle changes are not enabled.');}
async decide(bot:Bot,decision:Decision){
if(!this.config.DB)throw new Error('Classic command database is unavailable');
const queued=await queueAleCommand(this.config.DB,classicCommand('intent',bot,decision.action));
return {summary:`${bot.name}: requested ${decision.action}; native receipt and observed outcome are pending (${queued.id}).`,zone:bot.zone};
}
}
// Add a connector factory here; personality and memory code remains game-independent.
export const connectors:Record<string,(config:RuntimeConfig)=>GameConnector>={simulation:()=>new SimulationConnector(),azerothcore:c=>new AzerothCoreConnector(c)};
export const connectors:Record<string,(config:RuntimeConfig)=>GameConnector>={simulation:()=>new SimulationConnector(),azerothcore:c=>c.GAME_BACKEND==='cmangos-classic'?new ClassicConnector(c):new AzerothCoreConnector(c)};