Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance Character Selection UX and Fix Minor Typos #153

Merged
merged 8 commits into from
Jan 18, 2025
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 3 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,18 +158,8 @@ Run the agent with a specific character:
yarn dev # for development with auto-reload
# or
yarn start # for production build and run

# Use a specific character (omit .yaml extension)
yarn dev my-agent # for development with auto-reload
# or
yarn start my-agent # for production build and run

# Examples:
# If your character file is named 'techie.yaml':
yarn dev techie
# If your character file is named 'my-agent.yaml':
yarn dev my-agent
```
Then, choose a character from the list of available characters.

Note: When specifying a character file, omit the `.yaml` extension. The system will automatically look for the YAML file in the `config/characters/` directory.

Expand Down Expand Up @@ -221,7 +211,7 @@ To use this feature:
1. Configure your AUTO_DRIVE_API_KEY in `.env` (obtain from https://ai3.storage)
2. Enable Auto Drive uploading in your `config.yaml`:
```yaml
autodrive:
auto_drive:
upload: true
```
3. Provide your Taurus EVM wallet details (PRIVATE_KEY) and Agent Memory Contract Address (CONTRACT_ADDRESS) in .env`
Expand All @@ -246,11 +236,8 @@ The KOL workflow enables agents to:
Start the agent with:

```bash
# Use default character
# Use example character
yarn dev

# Use a specific character (without .ts extension)
yarn dev my-agent
```

Monitor the agent's activity in the console and configured log files.
Expand Down
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{
"name": "auto-agents-framework",
"version": "0.0.1",
"version": "0.1.0",
"description": "Auto Agents Framework",
"main": "dist/index.js",
"type": "module",
"scripts": {
"build": "tsc && yarn copy-characters",
"start": "yarn build && node dist/index.js",
"dev": "tsx watch src/index.ts",
"dev": "NODE_ENV=development tsx --no-cache --watch src/index.ts",
"format": "prettier --write \"src/**/*.ts\" \"tests/**/*.ts\"",
"format:check": "prettier --check \"src/**/*.ts\" \"tests/**/*.ts\"",
"example:twitter": "tsx examples/twitter.ts",
Expand All @@ -33,13 +33,15 @@
"agent-twitter-client": "0.0.18",
"dotenv": "^16.3.1",
"ethers": "^6.13.4",
"inquirer": "^10.2.0",
"winston": "^3.11.0",
"zod": "^3.22.4",
"zod-to-json-schema": "^3.24.1"
},
"devDependencies": {
"@eslint/js": "^9.18.0",
"@tsconfig/node20": "^20.1.4",
"@types/inquirer": "^9.0.7",
"@types/jest": "^29.5.12",
"@types/js-yaml": "^4.0.9",
"@types/node": "22.10.0",
Expand Down
28 changes: 28 additions & 0 deletions src/cli/onboarding.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import inquirer from 'inquirer';
import { createLogger } from '../utils/logger.js';
import { listAvailableCharacters } from './utils/characterLoader.js';

const logger = createLogger('onboarding');

interface UserAnswers {
character: string;
}

export const onboarding = async (): Promise<UserAnswers> => {
const characters = await listAvailableCharacters();

const answers: UserAnswers = await inquirer.prompt([
{
type: 'list',
name: 'character',
message: 'Select a character to run the workflow:',
choices: characters.map(char => ({
name: `${char.id} - ${char.description.split('.')[0]}`,
value: char.id,
})),
},
]);
logger.info(`Character: ${answers.character}`);

return answers;
};
30 changes: 30 additions & 0 deletions src/cli/utils/characterLoader.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { readdir } from 'fs/promises';
import { join } from 'path';
import { loadCharacter } from '../../config/characters.js';

interface CharacterInfo {
id: string;
name: string;
description: string;
username: string;
}

export const listAvailableCharacters = async (): Promise<CharacterInfo[]> => {
const charactersPath = join(process.cwd(), 'config', 'characters');
const files = await readdir(charactersPath);
const characterFiles = files.filter(file => file.endsWith('.yaml'));

const characters = await Promise.all(
characterFiles.map(async file => {
const id = file.replace(/\.yaml$/, '');
const character = loadCharacter(id);
return {
id,
name: character.name,
description: character.description,
username: character.username,
};
}),
);
return characters;
};
30 changes: 20 additions & 10 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
import { config } from './config/index.js';
import { createLogger } from './utils/logger.js';
import { runWorkflow } from './agents/workflows/kol/workflow.js';
import { onboarding } from './cli/onboarding.js';

const logger = createLogger('app');

// Get character name from command line args
const characterId = process.argv[2];
if (!characterId) {
logger.error('Please provide a character name as an argument (e.g., yarn dev argumint)');
process.exit(1);
}
jfrank-summit marked this conversation as resolved.
Show resolved Hide resolved
process.on('SIGINT', () => {
logger.info('Received SIGINT. Gracefully shutting down...');
process.exit(0);
});

// Strip any file extension
const cleanCharacterId = characterId.replace(/\.(ya?ml)$/, '');
process.on('SIGTERM', () => {
logger.info('Received SIGTERM. Gracefully shutting down...');
process.exit(0);
});

const startWorkflowPolling = async () => {
try {
const _result = await runWorkflow(cleanCharacterId);
logger.info('Workflow execution completed successfully');
const character = await onboarding();
const _result = await runWorkflow(character.character);
logger.info('Workflow execution completed successfully for character:', character.character);
} catch (error) {
if (error && typeof error === 'object' && 'name' in error && error.name === 'ExitPromptError') {
logger.info('Process terminated by user');
process.exit(0);
}
logger.error('Error running workflow:', error);
}
};
Expand All @@ -33,6 +39,10 @@ const main = async () => {
username: config.twitterConfig.USERNAME,
});
} catch (error) {
if (error && typeof error === 'object' && 'name' in error && error.name === 'ExitPromptError') {
logger.info('Process terminated by user');
process.exit(0);
}
logger.error('Failed to start application:', error);
process.exit(1);
}
Expand Down
Loading
Loading