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

chore: Write agent app README #75

Merged
merged 5 commits into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
4 changes: 3 additions & 1 deletion apps/agent/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
PROTOCOL_PROVIDER_PRIVATE_KEY=afdfd9c3d2095ef696594f6cedcae59e72dcd697e2a7521b1578140422a4f890
BLOCK_NUMBER_BLOCKMETA_TOKEN=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJuaWNlIjoidHJ5Iiwibm90aGluZyI6InRvIiwic2VlIjoiaGVyZSJ9.gsWpvMzpzd5_7IN_GU0PhNLH7wuKHl29FHkL5-i18b4
EBO_AGENT_CONFIG_FILE_PATH="./config.example.yml"
EBO_AGENT_CONFIG_FILE_PATH="./config.example.yml"
DISCORD_BOT_TOKEN=YOUR_DISCORD_BOT_TOKEN
DISCORD_CHANNEL_ID=YOUR_DISCORD_CHANNEL_ID
91 changes: 91 additions & 0 deletions apps/agent/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# Agent Monorepo

The `agent` package is designed as a service that drives the EBO agent's main workflow. It initializes the relevant
services in the `packages` directory that are necessary to run the agent, like `BlockNumberService` and `ProtocolProvider`.
The agent interacts with the EBO smart contracts deployed on the chains specified in the `config.yml` file
that you'll create during this setup process.

## Setup

To set up the EBO agent, follow these steps:

1. **Install Dependencies**: Ensure you have `pnpm` installed, and run:

```bash
pnpm install
```

2. **Configure Environment Variables**:

- Create a `.env` file in the root of the `agent` package. Refer to `.env.example` for the required environment variables.
- Populate the file with your environment-specific settings:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Creating a .env file is optional, users could (and probably should but it's up to them) use env vars directly while running the agent. Let's rephrase this one just to show that's not a must to use a .env file

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mentioned the option to use the env vars directly


```bash
cp .env.example .env
```

**Environment Variables**:

| Variable | Description | Required |
| ------------------------------- | ----------------------------------------- | -------- |
| `PROTOCOL_PROVIDER_PRIVATE_KEY` | Private key for the Protocol Provider | Yes |
| `BLOCK_NUMBER_BLOCKMETA_TOKEN` | BlockmetaBlockNumberService bearer token | Yes |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Now that I'm thinking, it'd be nice to add a link or something like that so potential contributors have at least some idea on how to get this token (was something that we struggled with)

Here are two of the main resources that we've used:

Mind adding some footnotes for this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added ✅

| `EBO_AGENT_CONFIG_FILE_PATH` | Path to the agent YAML configuration file | Yes |
| `DISCORD_BOT_TOKEN` | Your Discord bot's token | Yes |
| `DISCORD_CHANNEL_ID` | Discord channel ID for notifications | Yes |

3. **Configuration File**:

- The agent also requires a YAML configuration file. The path to this file must be specified in the `.env` file via `EBO_AGENT_CONFIG_FILE_PATH`.
- To set up the configuration, copy `config.example.yml` to `config.yml`:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if we should add explanatory comments inside the config.example.yml file for each of its properties or to add some kind of doc here. I feel like adding comments inside the yml file might be easier to update as they'd be super co-located.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added comments in config.example.yml

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! I like it


```bash
cp config.example.yml config.yml
```

- Update the `config.yml` file with your specific settings.

## Available Scripts

Here are the scripts you can run using `pnpm`:

| Script | Description |
| ------------- | ---------------------------------------------- |
| `build` | Build the agent |
| `check-types` | Check for type issues using TypeScript |
| `clean` | Remove `dist` folder |
| `format` | Check code formatting using Prettier |
| `format:fix` | Automatically fix code formatting issues |
| `lint` | Run ESLint to check for code quality and style |
| `lint:fix` | Automatically fix ESLint errors |
| `start` | Start the EBO Agent |
| `test` | Run tests using Vitest |
| `test:cov` | Run tests with a coverage report |

### Running the Agent

To start the EBO Agent, run:

```bash
pnpm run start
```

## Running Tests

The `agent` package includes a suite of Vitest and end-to-end (e2e) tests to verify the correct functioning of the agent's processes. To run the Vitest tests, execute:

```bash
pnpm run test
```

For a coverage report, run:

```bash
pnpm run test:cov
```

### End-to-End Testing

The e2e tests simulate scenarios starting at the contract level and extending to the agent, like processing requests and handling disputes. For detailed test scenarios, refer to the files in `test/e2e/scenarios`.

TODO: Add instructions on running e2e tests
4 changes: 2 additions & 2 deletions apps/scripts/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# EBO Agent Monorepo
# Scripts Monorepo

This monorepo contains the EBO Agent scripts and packages.
This monorepo contains scripts relevant to running the EBO agent, such as approving its required modules

## Setup

Expand Down