mindcraft/controller/init-agent.js

34 lines
992 B
JavaScript
Raw Normal View History

2023-12-09 21:40:53 -06:00
import { Agent } from '../agent.js';
2023-12-08 16:18:20 -06:00
import yargs from 'yargs';
const args = process.argv.slice(2);
if (args.length < 1) {
2023-12-10 20:18:20 -06:00
console.log('Usage: node init_agent.js <agent_name> [-c] [-a]');
2023-12-08 16:18:20 -06:00
process.exit(1);
}
const argv = yargs(args)
2023-12-12 21:35:39 -08:00
.option('profile', {
alias: 'p',
type: 'string',
description: 'profile to use for agent'
})
2023-12-10 20:18:20 -06:00
.option('clear_memory', {
alias: 'c',
2023-12-08 16:18:20 -06:00
type: 'boolean',
description: 'restart memory from scratch'
2023-12-10 20:18:20 -06:00
})
.option('autostart', {
alias: 'a',
type: 'boolean',
description: 'automatically prompt the agent on startup'
}).argv
2023-12-08 16:18:20 -06:00
const name = argv._[0];
const save_path = './bots/'+name+'.json';
2023-12-12 21:35:39 -08:00
const profile = argv.profile;
const load_path = !!argv.clear_memory ? './bots/'+profile+'.json' : save_path;
const init_message = !!argv.autostart ? 'Agent process restarted. Notify the user and decide what to do.' : null;
2023-12-08 16:18:20 -06:00
2023-12-12 21:35:39 -08:00
new Agent(name, save_path, load_path, init_message);