mindcraft/main.js
Nimi 418a2470de Server/Minecraft data now agent-level
Also refactored mcdata as a class.
2024-11-14 15:00:53 -06:00

42 lines
No EOL
1.1 KiB
JavaScript

import { AgentProcess } from './src/process/agent-process.js';
import settings from './settings.js';
import yargs from 'yargs';
import { hideBin } from 'yargs/helpers';
import { getServer } from './src/utils/mcserver.js';
function parseArguments() {
return yargs(hideBin(process.argv))
.option('profiles', {
type: 'array',
describe: 'List of agent profile paths',
})
.help()
.alias('help', 'h')
.parse();
}
function getProfiles(args) {
return args.profiles || settings.profiles;
}
async function main() {
const args = parseArguments();
const profiles = getProfiles(args);
console.log(profiles);
const { load_memory, init_message } = settings;
// Get server
const server = await getServer();
for (let i=0; i<profiles.length; i++) {
const agent = new AgentProcess();
agent.start(profiles[i], load_memory, init_message, server.host, server.port, server.version, i);
}
}
try {
main();
} catch (error) {
console.error('An error occurred:', error);
process.exit(1);
}