mirror of
https://github.com/kolbytn/mindcraft.git
synced 2025-08-04 14:25:43 +02:00
49 lines
1.4 KiB
JavaScript
49 lines
1.4 KiB
JavaScript
import { Agent } from '../agent/agent.js';
|
|
import yargs from 'yargs';
|
|
|
|
// Add global unhandled rejection handler
|
|
process.on('unhandledRejection', (reason, promise) => {
|
|
console.error('Unhandled Rejection at:', promise);
|
|
console.error('Reason:', reason);
|
|
process.exit(1);
|
|
});
|
|
|
|
const args = process.argv.slice(2);
|
|
if (args.length < 1) {
|
|
console.log('Usage: node init_agent.js <agent_name> [profile] [load_memory] [init_message]');
|
|
process.exit(1);
|
|
}
|
|
|
|
const argv = yargs(args)
|
|
.option('profile', {
|
|
alias: 'p',
|
|
type: 'string',
|
|
description: 'profile filepath to use for agent'
|
|
})
|
|
.option('load_memory', {
|
|
alias: 'l',
|
|
type: 'boolean',
|
|
description: 'load agent memory from file on startup'
|
|
})
|
|
.option('init_message', {
|
|
alias: 'm',
|
|
type: 'string',
|
|
description: 'automatically prompt the agent on startup'
|
|
})
|
|
.option('count_id', {
|
|
alias: 'c',
|
|
type: 'number',
|
|
default: 0,
|
|
description: 'identifying count for multi-agent scenarios',
|
|
}).argv;
|
|
|
|
// Wrap agent start in async IIFE with proper error handling
|
|
(async () => {
|
|
try {
|
|
const agent = new Agent();
|
|
await agent.start(argv.profile, argv.load_memory, argv.init_message, argv.count_id);
|
|
} catch (error) {
|
|
console.error('Failed to start agent:', error);
|
|
process.exit(1);
|
|
}
|
|
})();
|