Import verified AzerothAI snapshot from GitHub
Core tests / core (push) Successful in 9m57s
Full verification / application (push) Failing after 5m16s
Full verification / local-brain (push) Failing after 6m15s
Realm simulation / simulated-live-world (push) Failing after 5m32s
WoW integration lab / real-worldserver (push) Canceled after 17m23s
Core tests / core (push) Successful in 9m57s
Full verification / application (push) Failing after 5m16s
Full verification / local-brain (push) Failing after 6m15s
Realm simulation / simulated-live-world (push) Failing after 5m32s
WoW integration lab / real-worldserver (push) Canceled after 17m23s
Source branch: feature/ai-brain-router Source commit: c2a09e0460465201a58aaab56c71424e9a96405e
This commit is contained in:
@@ -0,0 +1,52 @@
|
||||
const base=(process.env.AZEROTHAI_URL||'http://127.0.0.1:8787').replace(/\/$/,'');
|
||||
const token=process.env.AUTONOMY_TOKEN;
|
||||
const autonomyInterval=Math.max(10_000,Number(process.env.AUTONOMY_POLL_MS||30_000));
|
||||
const conversationInterval=Math.max(500,Number(process.env.CONVERSATION_POLL_MS||1000));
|
||||
|
||||
if(!token){
|
||||
console.error('AUTONOMY_TOKEN is required');
|
||||
process.exit(2);
|
||||
}
|
||||
|
||||
let stopping=false;
|
||||
for(const signal of ['SIGINT','SIGTERM'])process.on(signal,()=>{stopping=true;});
|
||||
|
||||
async function post(path,timeout=60_000){
|
||||
const response=await fetch(`${base}${path}`,{
|
||||
method:'POST',
|
||||
headers:{Authorization:`Bearer ${token}`,'Content-Type':'application/json'},
|
||||
body:'{}',
|
||||
signal:AbortSignal.timeout(timeout)
|
||||
});
|
||||
const raw=await response.text();
|
||||
if(!response.ok)throw new Error(`${path} HTTP ${response.status}: ${raw.slice(0,500)}`);
|
||||
try{return JSON.parse(raw);}catch{return {raw};}
|
||||
}
|
||||
|
||||
async function autonomyTick(){
|
||||
const body=await post('/api/autonomy/tick');
|
||||
const stamp=new Date().toISOString();
|
||||
if(body.ran)console.log(`[${stamp}] ${body.name}: ${body.decision?.action} -> command ${body.commandId}`);
|
||||
else console.log(`[${stamp}] idle: ${body.reason||'no due resident'}`);
|
||||
}
|
||||
|
||||
async function conversationTick(){
|
||||
const body=await post('/api/conversation/tick');
|
||||
if(body.ran){
|
||||
console.log(`[${new Date().toISOString()}] chat: ${body.name} -> ${body.speaker}: ${body.reply} (command ${body.commandId})`);
|
||||
}
|
||||
}
|
||||
|
||||
console.log(`AzerothAI autonomy worker starting: ${base}, autonomy ${autonomyInterval}ms, conversation ${conversationInterval}ms`);
|
||||
let nextAutonomy=0;
|
||||
while(!stopping){
|
||||
try{await conversationTick();}catch(e){console.error(`[${new Date().toISOString()}] ${e instanceof Error?e.message:String(e)}`);}
|
||||
if(stopping)break;
|
||||
if(Date.now()>=nextAutonomy){
|
||||
try{await autonomyTick();}catch(e){console.error(`[${new Date().toISOString()}] ${e instanceof Error?e.message:String(e)}`);}
|
||||
nextAutonomy=Date.now()+autonomyInterval;
|
||||
}
|
||||
if(stopping)break;
|
||||
await new Promise(resolve=>setTimeout(resolve,conversationInterval));
|
||||
}
|
||||
console.log('AzerothAI autonomy worker stopped.');
|
||||
Reference in New Issue
Block a user