Installation

This guide covers the complete installation and setup of the Autonomous Incident Agent (AIA).

#Prerequisites

Before proceeding, ensure you have:

  • Bun: v1.2 or later (Install Bun)
  • Git: For cloning the repository
  • GitHub Account: For PR creation
  • You.com API Key: For AI analysis (Get API Key)
  • PostgreSQL Database: We recommend Neon (free tier available)

#Step 1: Clone Repository

Terminal
git clone https://github.com/sarthakNITT/autonomous-incident-agent cd autonomous-incident-agent

#Step 2: Install Dependencies

Terminal
bun install

This installs all dependencies for the monorepo workspace.

#Step 3: Create GitHub Personal Access Token

  1. Go to GitHub Settings → Developer Settings → Personal Access Tokens
  2. Click "Generate new token (classic)"
  3. Give it a name (e.g., "AIA Bot")
  4. Select scope: repo (Full control of private repositories)
  5. Click "Generate token"
  6. Copy the token (starts with ghp_)

#Step 4: Get You.com API Key

  1. Visit You.com
  2. Sign up or log in
  3. Navigate to API settings
  4. Generate an API key
  5. Copy the key (starts with ydc-)

#Step 5: Set Up Database

  1. Go to Neon
  2. Create a free account
  3. Create a new project
  4. Copy the connection string (looks like postgresql://user:pass@host/db)

Option B: Local PostgreSQL

Terminal
# Install PostgreSQL brew install postgresql # macOS # or sudo apt install postgresql # Linux # Create database createdb aia_db # Connection string postgresql://localhost/aia_db

#Step 6: Configure Environment

Create a .env file in the project root:

.env
# AI Configuration YOU_API_KEY=ydc_your_actual_key_here # GitHub Configuration GITHUB_TOKEN=ghp_your_actual_token_here # Database Configuration DATABASE_URL=postgresql://user:pass@host/db # Optional: R2 Storage (for autopsy backups) R2_ACCESS_KEY_ID=your_r2_access_key R2_SECRET_ACCESS_KEY=your_r2_secret_key R2_BUCKET_NAME=aia R2_ACCOUNT_ID=your_account_id

#Step 7: Configure GitHub Repository

Create aia.config.local.yaml (gitignored):

aia.config.local.yaml
github: provider: "github" token: "PLACEHOLDER" # Read from .env owner: "your-github-username" # REQUIRED repo: "your-repo-name" # REQUIRED base_branch: "main"

Example:

  • If your repo is https://github.com/johndoe/my-app
  • Set owner: "johndoe"
  • Set repo: "my-app"

#Step 8: Verify TypeScript

Ensure no type errors:

Terminal
bun run check-types

#Step 9: Start Services

Terminal
bun run dev

This starts all services:

  • Agent (OTEL): http://localhost:4318
  • Dashboard: http://localhost:3000
  • Router: http://localhost:3001
  • Autopsy: http://localhost:3002
  • State: http://localhost:3003
  • Git: http://localhost:3004
  • Web: http://localhost:3006
  • Docs: http://localhost:3007
  • Sample App: http://localhost:3008

#Step 10: Test the System

Trigger a test incident:

Terminal
curl -X POST http://localhost:3008/trigger \ -H "Content-Type: application/json" \ -d '{"action":"cause_error"}'

Then:

  1. Check dashboard: http://localhost:3000
  2. View autopsy results
  3. Check your GitHub repo for a new PR

#Troubleshooting

"Command not found: bun"

Install Bun: curl -fsSL https://bun.sh/install | bash

"GitHub token invalid"

  • Ensure token has repo scope
  • Check token hasn't expired
  • Verify token is correctly set in .env

"Database connection failed"

  • Verify DATABASE_URL is correct
  • Check database is running
  • Ensure network allows connection

"You.com API error"

  • Verify API key is correct
  • Check you have API credits
  • Ensure key starts with ydc-

"TypeScript errors"

Run bun run check-types to see specific errors

"Port already in use"

Another service is using the port. Stop it or change ports in aia.config.yaml

#Next Steps