diff --git a/README.md b/README.md index 79a8616..92fc684 100644 --- a/README.md +++ b/README.md @@ -61,6 +61,11 @@ Bot profiles are json files (such as `andy.json`) that define: 2. Prompts used to influence the bot's behavior. 3. Examples help the bot perform tasks. +### Specifying Profiles via Command Line + +By default, the program will use the profiles specified in `settings.js`. You can specify one or more agent profiles using the `--profiles` argument: + +`node main.js --profiles ./profiles/andy.json ./profiles/jill.json` ### Model Specifications diff --git a/main.js b/main.js index 3292f7e..fbd5b78 100644 --- a/main.js +++ b/main.js @@ -1,9 +1,37 @@ import { AgentProcess } from './src/process/agent-process.js'; import settings from './settings.js'; +import yargs from 'yargs'; +import { hideBin } from 'yargs/helpers'; -let profiles = settings.profiles; -let load_memory = settings.load_memory; -let init_message = settings.init_message; +function parseArguments() { + return yargs(hideBin(process.argv)) + .option('profiles', { + type: 'array', + describe: 'List of agent profile paths', + }) + .help() + .alias('help', 'h') + .parse(); +} -for (let profile of profiles) - new AgentProcess().start(profile, load_memory, init_message); \ No newline at end of file +function getProfiles(args) { + return args.agents || settings.profiles; +} + +function main() { + const args = parseArguments(); + const profiles = getProfiles(args); + const { load_memory, init_message } = settings; + + for (const profile of profiles) { + const agent = new AgentProcess(); + agent.start(profile, load_memory, init_message); + } +} + +try { + main(); +} catch (error) { + console.error('An error occurred:', error); + process.exit(1); +} \ No newline at end of file