### Install AI Infrastructure Agent Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/getting-started.md This snippet clones the AI Infrastructure Agent repository and runs an automated installation script. The script handles Go dependencies, application building, directory creation, and configuration setup. ```bash # Clone the repository git clone https://github.com/VersusControl/ai-infrastructure-agent.git cd ai-infrastructure-agent # Run the automated installation script ./scripts/install.sh ``` -------------------------------- ### Start AI Infrastructure Agent Web UI Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md Starts the web UI for the AI Infrastructure Agent using a provided script. The web interface will then be accessible at http://localhost:8080. This is used after the Bash script installation. ```bash # Start the Web UI ./scripts/run-web-ui.sh ``` -------------------------------- ### Copy Anthropic Example Configuration Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/anthropic-api-setup.md This command demonstrates how to copy the example configuration file for Anthropic to use as the primary config.yaml for the AI Infrastructure Agent. This is a convenient way to start with a pre-defined setup. ```bash # Copy the Anthropic example config cp config.anthropic.yaml.example config.yaml ``` -------------------------------- ### Start the AI Infrastructure Agent Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/anthropic-api-setup.md These commands show how to start the AI infrastructure agent. The first command starts the agent with default settings, while the second allows specifying a configuration file for explicit setup. Ensure the agent executable is in your PATH or provide the full path. ```bash # Start the agent with Anthropic Claude ./bin/web-ui # Or with explicit config ./bin/web-ui -config config.anthropic.yaml ``` -------------------------------- ### Run AI Infrastructure Agent Bash Installation Script Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md Makes the installation script executable and runs it to set up the AI Infrastructure Agent. This script handles Go installation, AWS CLI setup, directory creation, dependency downloads, configuration, and building the application. Requires Go 1.24.2+. ```bash # Make the script executable and run it chmod +x scripts/install.sh ./scripts/install.sh ``` -------------------------------- ### Example Infrastructure Request (EC2) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/getting-started.md This is a natural language prompt to create an EC2 instance for hosting an Apache server. It specifies security group rules for HTTP and SSH, and uses the default VPC. An alternative example shows how to specify a VPC ID. ```natural_language Create an EC2 instance for hosting an Apache Server with a dedicated security group that allows inbound HTTP (port 80) and SSH (port 22) traffic using the default VPC. ``` ```natural_language Create an EC2 instance for hosting an Apache Server with a dedicated security group that allows inbound HTTP (port 80) and SSH (port 22) traffic using the VPC with ID vpc-1234501ec3e750243. ``` -------------------------------- ### Start Ollama Server Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Command to start the Ollama local server if it's not running. This is often a necessary step when troubleshooting connection refused errors. ```bash ollama serve ``` -------------------------------- ### Configure AI Provider API Keys Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/getting-started.md These snippets demonstrate how to copy example configuration files and prepare them for different AI providers. Users need to edit the copied 'config.yaml' with their specific API keys or model preferences. ```bash # Option A: OpenAI (Recommended) cp config.openai.yaml.example config.yaml # Edit config.yaml with your OpenAI API key ``` ```bash # Option B: Google Gemini cp config.gemini.yaml.example config.yaml # Edit config.yaml with your Gemini API key ``` ```bash # Option C: Anthropic Claude cp config.anthropic.yaml.example config.yaml # Edit config.yaml with your Anthropic API key ``` ```bash # Option D: AWS Bedrock Nova cp config.bedrock.yaml.example config.yaml # Configure AWS credentials for Bedrock access ``` ```bash # Option E: Ollama (Local LLM) cp config.ollama.yaml.example config.yaml # Edit config.yaml with your preferred model ``` -------------------------------- ### Start AI Infrastructure Agent Web UI Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/getting-started.md This command initiates the web UI for the AI Infrastructure Agent. After running this script, the user should navigate to http://localhost:8080 in their browser to access the dashboard. ```bash ./scripts/run-web-ui.sh ``` -------------------------------- ### Configure AWS Bedrock for AI Infrastructure Agent Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md Copies the example AWS Bedrock configuration to `config.yaml`. No API key is needed as it utilizes existing AWS credentials. This is part of the environment configuration for the Bash script installation. ```bash # No API key needed - uses AWS credentials cp config.bedrock.yaml.example config.yaml ``` -------------------------------- ### Configure Google Gemini API Key for AI Infrastructure Agent Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md Sets the Google Gemini API key as an environment variable and copies the example Gemini configuration to `config.yaml`. This is part of the environment configuration for the Bash script installation. ```bash # Set your API key export GEMINI_API_KEY="your-gemini-api-key-here" # Update config.yaml cp config.gemini.yaml.example config.yaml ``` -------------------------------- ### Download and Run Ollama Models Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Demonstrates how to pull a specific LLM model (e.g., gemma3:27b) into Ollama for local inference and how to run it interactively or with a specific prompt. Requires Ollama to be installed. ```bash # Pull the model (downloads to your machine) ollama pull gemma3:27b # Test the model interactively ollama run gemma3:27b ``` ```bash ollama run gemma3:27b "What is AWS EC2?" ``` ```bash # View all downloaded models ollama list ``` -------------------------------- ### Clone AI Infrastructure Agent Repository Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md Clones the AI Infrastructure Agent repository from GitHub and navigates into the project directory. This is the initial step for the Bash script installation method. ```bash # Clone the repository git clone https://github.com/VersusControl/ai-infrastructure-agent.git cd ai-infrastructure-agent ``` -------------------------------- ### Install Ollama on macOS/Linux/Windows (WSL2) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Installs Ollama using a convenient script. This method is suitable for macOS, Linux, and Windows Subsystem for Linux 2 (WSL2). Ensure you have curl installed. ```bash curl -fsSL https://ollama.com/install.sh | sh ``` -------------------------------- ### Install Ollama using Homebrew on macOS Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Installs Ollama via the Homebrew package manager on macOS. This is an alternative to the script-based installation and requires Homebrew to be pre-installed. ```bash brew install ollama ``` -------------------------------- ### Start AI Infrastructure Agent Web UI (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/aws-bedrock-nova-setup.md This command sets the default AWS region and then starts the AI Infrastructure Agent's web UI. It's crucial for verifying that the agent initializes correctly and can communicate with the configured Nova models. Checking logs is recommended for confirmation. ```bash # Set environment export AWS_DEFAULT_REGION="us-east-1" # Start the web UI ./scripts/run-web-ui.sh # Check logs for successful Nova initialization tail -f logs/app.log ``` -------------------------------- ### Start Remote Ollama Server Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Starts the Ollama service on a remote server, configured to accept network connections from any IP address. This allows the AI Infrastructure Agent on a different machine to connect to this Ollama instance. ```bash OLLAMA_HOST=0.0.0.0:11434 ollama serve ``` -------------------------------- ### Configure OpenAI API Key for AI Infrastructure Agent Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md Sets the OpenAI API key as an environment variable and copies the example OpenAI configuration to `config.yaml`. This is part of the environment configuration for the Bash script installation. ```bash # Set your API key export OPENAI_API_KEY="sk-your-openai-api-key-here" # Update config.yaml cp config.openai.yaml.example config.yaml ``` -------------------------------- ### Manage AI Infrastructure Agent with Docker Compose Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md Provides commands to manage the AI Infrastructure Agent service using Docker Compose. Includes starting the application in detached mode (`up -d`), viewing logs (`logs -f`), and stopping the application (`down`). ```bash # Start with Docker Compose docker-compose up -d # View logs docker-compose logs -f # Stop the application docker-compose down ``` -------------------------------- ### Start Web UI with Bash Script (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/README.md This command executes a bash script to start the Web UI for the AI Infrastructure Agent after installation. ```bash ./scripts/run-web-ui.sh ``` -------------------------------- ### Configure AI Infrastructure Agent for Local Ollama Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Shows how to configure the AI Infrastructure Agent to use a locally running Ollama instance. This involves copying an example configuration file and editing it to specify the Ollama provider and desired model. ```bash cp config.ollama.yaml.example config.yaml ``` ```yaml agent: provider: "ollama" model: "gemma3:27b" # or "gemma3", "llama3.2", etc. max_tokens: 8192 temperature: 0.1 ``` -------------------------------- ### Configure AWS Credentials Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/getting-started.md This snippet shows two methods for configuring AWS credentials. The recommended method uses the AWS CLI ('aws configure'), while the alternative sets environment variables for access key, secret key, and default region. ```bash # Method 1: Using AWS CLI (recommended) aws configure # Method 2: Environment variables export AWS_ACCESS_KEY_ID="your-access-key" export AWS_SECRET_ACCESS_KEY="your-secret-key" export AWS_DEFAULT_REGION="us-west-2" ``` -------------------------------- ### Run AI Infrastructure Agent with Docker Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md Starts the AI Infrastructure Agent in a Docker container in detached mode. It maps port 8080, mounts the `config.yaml` and `states` directories, and sets necessary environment variables for API keys and AWS credentials. The image used is `ghcr.io/versuscontrol/ai-infrastructure-agent`. ```bash docker run -d \ --name ai-infrastructure-agent \ -p 8080:8080 \ -v $(pwd)/config.yaml:/app/config.yaml:ro \ -v $(pwd)/states:/app/states \ -e OPENAI_API_KEY="your-openai-api-key-here" \ -e AWS_ACCESS_KEY_ID="your-aws-access-key" \ -e AWS_SECRET_ACCESS_KEY="your-aws-secret-key" \ -e AWS_DEFAULT_REGION="us-west-2" \ ghcr.io/versuscontrol/ai-infrastructure-agent ``` -------------------------------- ### AI Infrastructure Agent Configuration (YAML) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/aws-bedrock-nova-setup.md This YAML snippet shows example configuration parameters for the AI Infrastructure Agent. It includes settings for the Bedrock provider, model selection (e.g., 'amazon.nova-micro-v1:0'), token limits, temperature, region, and debug mode. Adjusting these can optimize performance and cost. ```yaml agent: provider: "bedrock" model: "amazon.nova-micro-v1:0" max_tokens: 6000 # Increase for complex tasks temperature: 0.1 # Lower for consistent outputs region: "us-east-1" # Choose closest region enable_debug: false # Disable in production ``` -------------------------------- ### YAML Configuration Example for AI Infrastructure Agent Source: https://context7.com/versuscontrol/ai-infrastructure-agent/llms.txt This is an example YAML configuration file for the AI infrastructure agent. It allows for flexible setup of AWS region, MCP server details, agent provider settings (OpenAI, Gemini, Anthropic, Bedrock, Ollama), logging levels and formats, state file management, and web server configurations. API keys and credentials should be set via environment variables. ```yaml # config.yaml - Example configuration aws: region: "us-west-2" mcp: server_name: "aws-infrastructure-server" version: "1.0.0" agent: # Provider options: openai, gemini, anthropic, bedrock, ollama provider: "openai" model: "gpt-4" max_tokens: 4000 temperature: 0.1 dry_run: true # Start with dry-run for safety auto_resolve_conflicts: false enable_debug: false step_delay_ms: 500 # Delay for frontend display # Set API keys via environment variables: # - OPENAI_API_KEY for OpenAI # - GEMINI_API_KEY for Google Gemini # - ANTHROPIC_API_KEY for Anthropic Claude # - AWS credentials for Bedrock # - OLLAMA_SERVER_URL for Ollama (optional) logging: level: "info" # debug, info, warn, error format: "text" # text or json output: "stdout" state: file_path: "./infrastructure.state" backup_enabled: true backup_dir: "./backups" web: port: 8080 host: "localhost" template_dir: "web/templates" static_dir: "web/static" enable_websockets: true ``` -------------------------------- ### Securely Store API Key in .env file (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/gemini-api-setup.md This example shows how to create a .env file to store sensitive information like the Gemini API key, and how to add this file to .gitignore to prevent accidental commits to version control. This is a common practice for managing environment-specific configurations securely. ```bash # Example .env file (never commit this) GEMINI_API_KEY=your-actual-key-here # Add to .gitignore echo ".env" >> .gitignore echo "config.yaml" >> .gitignore ``` -------------------------------- ### Check Ollama Service Status Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Command to verify if the Ollama service is running and accessible. If it's not running, you can start it using 'ollama serve'. ```bash curl http://localhost:11434/api/version ``` -------------------------------- ### Verify Gemini API Key and Connectivity (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/gemini-api-setup.md Tests the validity of the GEMINI_API_KEY by echoing it to the console and then making a simple API call using curl. This helps troubleshoot 'API key not valid' errors and confirms basic API access. ```bash # Verify your key is set correctly echo $GEMINI_API_KEY # Test with curl curl -H "Content-Type: application/json" \ -d '{"contents":[{"parts":[{"text":"Hello"}]}]}' \ "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=$GEMINI_API_KEY" ``` ```bash # Simple test request curl -H "Content-Type: application/json" \ -d '{ "contents": [{ "parts": [{"text": "Respond with: API key working correctly"}] }] }' \ "https://generativelanguage.googleapis.com/v1beta/models/gemini-pro:generateContent?key=$GEMINI_API_KEY" ``` -------------------------------- ### Create Data Directory for Docker Installation Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md Creates the `states` subdirectory, which is used for data persistence when running the AI Infrastructure Agent with Docker. This directory should be created in the root directory where `config.yaml` will be placed. ```bash # Create subdirectories for data persistence mkdir -p states ``` -------------------------------- ### Usage Examples for AI Infrastructure Agent (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/README.md These are example commands or natural language prompts demonstrating how to use the AI Infrastructure Agent for various infrastructure tasks, such as creating EC2 instances, setting up web servers, configuring databases, and deploying complete environments. ```bash # Simple EC2 instance "Create a t3.micro EC2 instance with Ubuntu 22.04" # Web server setup "Deploy a load-balanced web application with 2 EC2 instances behind an ALB" # Database setup "Create an RDS MySQL database with read replicas in multiple AZs" # Complete environment "Set up a development environment with VPC, subnets, EC2, and RDS" ``` -------------------------------- ### Pull Any Ollama Model Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md A general command to download any available model from Ollama's registry to your local machine. Replace `` with the desired model identifier, such as `gemma3:27b` or `llama3.2`. ```bash ollama pull # e.g., ollama pull gemma3:27b ``` -------------------------------- ### Verify API Key (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md This snippet shows how to verify if an API key, specifically OPENAI_API_KEY, is correctly set. It includes a command to echo the environment variable and another to check it within a Docker container. ```bash # Verify API key is set correctly echo $OPENAI_API_KEY # For Docker, check container environment docker exec ai-infrastructure-agent env | grep OPENAI_API_KEY ``` -------------------------------- ### Create config.yaml for Docker Installation Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md Defines the configuration for the AI Infrastructure Agent by creating a `config.yaml` file. This file specifies server settings, AWS region, agent provider and model, logging, state management, and web interface details. It should be placed in the root directory. ```yaml # AI Infrastructure Agent Configuration server: port: 3000 host: "0.0.0.0" aws: region: "us-west-2" # Change to your preferred region mcp: server_name: "ai-infrastructure-agent" version: "1.0.0" agent: provider: "openai" # openai, gemini, anthropic, bedrock, ollama model: "gpt-4o-mini" max_tokens: 4000 temperature: 0.1 dry_run: false auto_resolve_conflicts: false logging: level: "info" format: "json" output: "stdout" state: file_path: "./states/infrastructure-state.json" backup_enabled: true backup_dir: "./backups" web: port: 8080 host: "0.0.0.0" template_dir: "web/templates" static_dir: "web/static" enable_websockets: true ``` -------------------------------- ### Check Disk Space Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Command to check available disk space, useful for troubleshooting model pulling failures that might be caused by insufficient storage. ```bash df -h ``` -------------------------------- ### Start EC2 Instance using modify action Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/settings/templates/tools-execution-context-optimized.txt This example shows how to start an EC2 instance using the 'modify' action and the 'start-ec2-instance' MCP tool. It takes an instance ID as a parameter, which can be dynamically provided from a previous step. This is used to change an instance's state to 'running'. ```json { "id": "step-start-instance", "name": "Start web server instance", "description": "Change instance state to running", "action": "modify", "resourceId": "web-server-1", "mcpTool": "start-ec2-instance", "toolParameters": { "instanceId": "{{step-create-instance.instanceId}}" }, "dependsOn": ["step-create-instance"], "status": "pending" } ``` -------------------------------- ### List Available AWS Bedrock Foundation Models Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/aws-bedrock-nova-setup.md This bash command uses the AWS CLI to list all available foundation models within a specified region. It's useful for verifying that Nova models have been successfully requested and are accessible. ```bash # List available models aws bedrock list-foundation-models --region us-east-1 # Check for Nova models in the output aws bedrock list-foundation-models --region us-east-1 | grep -i nova ``` -------------------------------- ### Pull and List Ollama Models Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Commands to manage models in Ollama. 'ollama pull ' downloads a model, and 'ollama list' displays all locally available models. Use exact model names with tags for troubleshooting 'model not found' errors. ```bash # Pull a model ullama pull # List available models ullama list ``` -------------------------------- ### Update Go Version (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md This snippet provides commands to update the Go programming language version to at least 1.24.2. It includes instructions for both macOS using Homebrew and Linux, where users need to download the binary from the official Go website. ```bash # Update Go to 1.24.2+ # macOS with Homebrew: brew install go # Linux: # Download from https://golang.org/dl/ ``` -------------------------------- ### Create IAM Policy and Attach to User (AWS CLI) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/aws-bedrock-nova-setup.md This set of bash commands illustrates creating an IAM policy from a JSON file, creating a new IAM user, attaching the policy to that user, and generating access keys for the user. This is a standard procedure for managing AWS access. ```bash # Save the JSON policy above as bedrock-nova-policy.json aws iam create-policy \ --policy-name BedrockNovaAccess \ --policy-document file://bedrock-nova-policy.json # Create IAM user (if not using existing user): aws iam create-user --user-name ai-infrastructure-agent # Attach policy to user: aws iam attach-user-policy \ --user-name ai-infrastructure-agent \ --policy-arn arn:aws:iam::YOUR-ACCOUNT-ID:policy/BedrockNovaAccess # Create access keys: aws iam create-access-key --user-name ai-infrastructure-agent ``` -------------------------------- ### Test Bedrock Access and Invoke Nova Model (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/aws-bedrock-nova-setup.md This snippet tests access to AWS Bedrock by listing all foundation models and then specifically invoking the 'amazon.nova-micro-v1:0' model with a sample prompt. The response is saved to a file for inspection, confirming successful interaction with the model. ```bash # List all foundation models aws bedrock list-foundation-models --region us-east-1 # Test Nova model specifically aws bedrock invoke-model \ --region us-east-1 \ --model-id amazon.nova-micro-v1:0 \ --body '{"messages":[{"role":"user","content":[{"text":"Hello, respond with: Bedrock Nova working correctly"}]}],"max_tokens":100,"temperature":0.1}' \ --cli-binary-format raw-in-base64-out \ /tmp/bedrock-response.json # View the response cat /tmp/bedrock-response.json ``` -------------------------------- ### Configure Gemini Agent Settings (YAML) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/gemini-api-setup.md Defines the custom settings for the Gemini provider, including model name, token limits, temperature, and Gemini-specific parameters like top_p and top_k. This configuration is used to tailor the agent's behavior and performance for specific tasks. ```yaml agent: provider: "gemini" model: "gemini-1.5-pro" max_tokens: 8000 temperature: 0.2 # Gemini-specific settings top_p: 0.8 top_k: 10 ``` ```yaml agent: provider: "gemini" model: "gemini-1.5-flash-002" max_tokens: 6000 temperature: 0.15 dry_run: true enable_debug: false ``` ```yaml # For cost-sensitive development agent: provider: "gemini" model: "gemini-1.5-flash-8b" max_tokens: 4000 temperature: 0.1 ``` ```yaml # For complex infrastructure planning agent: provider: "gemini" model: "gemini-1.5-pro-002" max_tokens: 8000 temperature: 0.1 ``` -------------------------------- ### Automated Bash Installation Script (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/README.md This bash script outlines the steps for installing the AI Infrastructure Agent using an automated script. It involves cloning the repository and then executing the provided installation script within the cloned directory. ```bash # Clone the repository git clone https://github.com/VersusControl/ai-infrastructure-agent.git cd ai-infrastructure-agent # Run the installation script ./scripts/install.sh ``` -------------------------------- ### Verify AWS Credentials (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/aws-bedrock-nova-setup.md This command verifies your current AWS credentials by retrieving your account ID, user ARN, and other identifying information. It's a fundamental step to ensure your AWS environment is properly configured before interacting with services like Bedrock. ```bash # Verify AWS credentials aws sts get-caller-identity # Should return your account ID, user ARN, etc. ``` -------------------------------- ### Docker Compose Configuration for AI Infrastructure Agent Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md Defines a `docker-compose.yml` file to manage the AI Infrastructure Agent service. It specifies the image, container name, restart policy, port mapping, volume mounts for configuration and data persistence, and environment variables for API keys and AWS credentials. ```yaml version: '3.8' services: ai-infrastructure-agent: image: ghcr.io/versuscontrol/ai-infrastructure-agent container_name: ai-infrastructure-agent restart: unless-stopped ports: - "8080:8080" volumes: # Mount configuration file (read-only) - ./config.yaml:/app/config.yaml:ro # Mount data directories (persistent) - ./states:/app/states environment: # AI Provider API Keys (choose one) - OPENAI_API_KEY=${OPENAI_API_KEY} # - GEMINI_API_KEY=${GEMINI_API_KEY} # - ANTHROPIC_API_KEY=${ANTHROPIC_API_KEY} # AWS Configuration - AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID} - AWS_SECRET_ACCESS_KEY=${AWS_SECRET_ACCESS_KEY} - AWS_DEFAULT_REGION=${AWS_DEFAULT_REGION:-us-west-2} ``` -------------------------------- ### Configure AI Agent with Gemini Provider (YAML) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/gemini-api-setup.md This YAML configuration snippet sets up the AI agent to use the Gemini provider. It specifies the model to be used (e.g., gemini-1.5-flash-002), the maximum number of tokens for responses, and the temperature for controlling creativity. This configuration is typically used in a config.yaml file. ```yaml agent: provider: "gemini" model: "gemini-1.5-flash-002" # Recommended for balanced performance and cost max_tokens: 4000 temperature: 0.1 ``` -------------------------------- ### Configure AWS CLI Credentials Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/aws-bedrock-nova-setup.md This snippet demonstrates how to configure your AWS Command Line Interface (CLI) with access keys, secret access keys, default region, and output format. It's a foundational step for interacting with AWS services like Bedrock. ```bash # Install AWS CLI if not already installed # Visit: https://aws.amazon.com/cli/ # Configure credentials aws configure ``` -------------------------------- ### Verify AWS Credentials (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md These bash commands help verify AWS credentials configuration and test access. 'aws configure list' shows the current configuration, 'aws sts get-caller-identity' tests the credentials, and 'docker exec' checks environment variables within a Docker container. ```bash # Check credentials configuration aws configure list # Test credentials aws sts get-caller-identity # For Docker, verify environment variables docker exec ai-infrastructure-agent env | grep AWS ``` -------------------------------- ### Single Value Reference Example Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/settings/templates/tools-execution-context-optimized.txt Demonstrates how to reference the output of a discovery step (e.g., VPC ID) as a parameter for another tool. ```json { "toolParameters": { "vpcId": "{{step-discover-vpc.vpcId}}" } } ``` -------------------------------- ### Prompt Engineering for OS Preferences Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/examples/working-with-ec2-instance.md Shows how to specify the desired operating system and AMI for an EC2 instance. This is important because different Linux distributions have distinct package managers and configurations, affecting software compatibility and management. ```text # Instead of this: Create an EC2 instance # Use this: Create an EC2 instance using Amazon Linux 2023 AMI # Or for Ubuntu: Create an EC2 instance using Ubuntu 22.04 LTS AMI ``` -------------------------------- ### Configure AI Provider for AI Infrastructure Agent Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/examples/working-with-vpc.md This set of commands demonstrates how to copy example configuration files to a main 'config.yaml' file, allowing you to specify your preferred AI provider (Google Gemini, OpenAI, or AWS Bedrock Nova). This configuration is essential for the agent to function. ```bash # For Google Gemini (Recommended) cp config.gemini.yaml.example config.yaml # For OpenAI cp config.openai.yaml.example config.yaml # For AWS Bedrock Nova cp config.bedrock.yaml.example config.yaml ``` -------------------------------- ### Set AWS Credentials via Environment Variables Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/aws-bedrock-nova-setup.md This example shows how to set AWS access key ID, secret access key, and default region using environment variables. This method is useful for scripting or when direct AWS CLI configuration is not desired. ```bash export AWS_ACCESS_KEY_ID="your-access-key-id" export AWS_SECRET_ACCESS_KEY="your-secret-access-key" export AWS_DEFAULT_REGION="us-east-1" ``` -------------------------------- ### Clone Repository and Navigate Directory Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/examples/working-with-vpc.md This snippet clones the AI Infrastructure Agent repository and changes the current directory to the cloned repository. This is the first step to set up the agent locally. ```bash git clone https://github.com/VersusControl/ai-infrastructure-agent.git cd ai-infrastructure-agent ``` -------------------------------- ### Manage Infrastructure State with Go Source: https://context7.com/versuscontrol/ai-infrastructure-agent/llms.txt This Go code demonstrates how to manage infrastructure state using the state package. It covers initializing the state manager, loading existing state, adding and retrieving resources, managing dependencies, and detecting state drift. It depends on the 'state', 'types', and 'logging' packages. ```go package main import ( "context" "log" "github.com/versus-control/ai-infrastructure-agent/pkg/state" "github.com/versus-control/ai-infrastructure-agent/pkg/types" "github.com/versus-control/ai-infrastructure-agent/internal/logging" ) func main() { ctx := context.Background() logger := logging.NewLogger("info", "text") // Initialize state manager stateManager := state.NewManager("./infrastructure.state", "us-west-2", logger) // Load existing state if err := stateManager.LoadState(ctx); err != nil { log.Printf("No existing state found, starting fresh: %v", err) } // Add a resource to state resource := &types.ResourceState{ ID: "i-0123456789abcdef0", Name: "web-server-01", Type: "instance", Status: "running", DesiredState: "running", CurrentState: "running", Tags: map[string]string{"Environment": "production"}, Properties: map[string]interface{}{ "instanceType": "t3.micro", "imageId": "ami-0abcdef1234567890", }, Dependencies: []string{"sg-0123456789abcdef0"}, } if err := stateManager.AddResource(ctx, resource); err != nil { log.Fatalf("Failed to add resource: %v", err) } // Add dependency relationship stateManager.AddDependency(ctx, "i-0123456789abcdef0", "sg-0123456789abcdef0") // Retrieve resource if res, exists := stateManager.GetResource("i-0123456789abcdef0"); exists { log.Printf("Found resource: %s (Type: %s, Status: %s)", res.Name, res.Type, res.Status) } // List all EC2 instances instances := stateManager.ListResources("instance") log.Printf("Total instances in state: %d", len(instances)) // Detect drift actualState := map[string]interface{}{ "instanceType": "t3.small", // Changed! "imageId": "ami-0abcdef1234567890", } if drift, err := stateManager.DetectDrift(ctx, actualState, "i-0123456789abcdef0"); err == nil && drift != nil { log.Printf("Drift detected: %s - %s", drift.ChangeType, drift.Reason) } // Get dependencies deps := stateManager.GetDependencies("i-0123456789abcdef0") log.Printf("Dependencies: %v", deps) // Get dependents dependents := stateManager.GetDependents("sg-0123456789abcdef0") log.Printf("Dependents: %v", dependents) } ``` -------------------------------- ### Basic EC2 Instance Request Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/examples/working-with-ec2-instance.md A natural language prompt to create a basic EC2 instance suitable for hosting an Apache web server. This input is processed by the AI agent to generate an execution plan. ```text Create an EC2 instance for hosting an Apache Server ``` -------------------------------- ### Configuration Loading in Go Source: https://context7.com/versuscontrol/ai-infrastructure-agent/llms.txt Loads configuration settings from multiple sources including files, environment variables, and default values. It allows for overrides via environment variables, ensuring flexibility in deployment. The loaded configuration is then used to set up agent parameters. ```go package main import ( "log" "github.com/versus-control/ai-infrastructure-agent/internal/config" ) func main() { // Load configuration from file, environment variables, and defaults cfg, err := config.Load() if err != nil { log.Fatalf("Failed to load configuration: %v", err) } // Access configuration values log.Printf("AWS Region: %s", cfg.AWS.Region) log.Printf("AI Provider: %s", cfg.Agent.Provider) log.Printf("Model: %s", cfg.Agent.Model) log.Printf("Dry Run: %t", cfg.Agent.DryRun) log.Printf("Web Port: %d", cfg.GetWebPort()) } ``` -------------------------------- ### Remove and Re-pull Ollama Model Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Commands to clear Ollama's cache for a specific model and then re-download it. This can resolve issues with corrupted model files or failed downloads. ```bash # Remove a model ullama rm # Then pull again ullama pull ``` -------------------------------- ### Troubleshoot Port Conflicts (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md This bash command helps identify processes using a specific port, such as 8080, which is commonly used by the AI Infrastructure Agent. It also suggests changing the port in configuration files if a conflict is found. ```bash # Find what's using port 8080 lsof -i :8080 # Change port in config.yaml or docker-compose.yml # Example: Change port to 8081 ``` -------------------------------- ### Verify GPU Usage Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Commands to check if GPU acceleration is active. Ollama automatically utilizes available GPUs. For NVIDIA, use 'nvidia-smi'. For Apple Silicon, monitor GPU usage via Activity Monitor. ```bash # NVIDIA nvidia-smi # Apple Silicon - check Activity Monitor > GPU tab ``` -------------------------------- ### Configure Remote Ollama Server URL via Environment Variable Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Sets the `OLLAMA_SERVER_URL` environment variable to specify the remote Ollama server address. This is an alternative method to configuring the agent via the `config.yaml` file. ```bash export OLLAMA_SERVER_URL="http://your-server-ip:11434" ./scripts/run-web-ui.sh ``` -------------------------------- ### Prompt Engineering for Security Requirements Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/examples/working-with-ec2-instance.md Illustrates how to provide detailed security group rules, including specific ports and IP address ranges. This ensures that security configurations are neither too permissive nor too restrictive, adhering to best practices. ```text # Instead of this: Create an EC2 with security group # Use this: Create an EC2 instance with a security group allowing HTTP (port 80) from 0.0.0.0/0 and SSH (port 22) from 203.0.113.25/32 ``` -------------------------------- ### Check Remote Ollama Server API Version Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Tests the connectivity to a remote Ollama server by querying its API version. This command should be run from the client machine to verify that the server is accessible over the network on port 11434. ```bash curl http://your-server-ip:11434/api/version ``` -------------------------------- ### Get default VPC using query action Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/settings/templates/tools-execution-context-optimized.txt This example demonstrates how to use the 'query' action with the 'get-default-vpc' MCP tool to find the default VPC in the current region. This is the recommended method for obtaining a VPC ID for resource placement. It returns the 'vpcId'. ```json { "id": "step-discover-vpc", "name": "Get default VPC", "description": "Find default VPC for resource placement", "action": "query", "resourceId": "vpc", "mcpTool": "get-default-vpc", "toolParameters": {}, "dependsOn": [], "status": "pending" } ``` -------------------------------- ### Prompt Engineering for VPC Specification Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/examples/working-with-ec2-instance.md Demonstrates how to be specific about VPC when creating an EC2 instance. Providing the default VPC or a specific VPC ID helps AI models avoid ambiguous resource placement. This improves consistency across different AI models. ```text # Instead of this: Create an EC2 instance # Use this: Create an EC2 instance using the default VPC # Or even better (if you know your VPC ID): Create an EC2 instance using VPC with ID vpc-1234567890abcdef0 ``` -------------------------------- ### Set Anthropic API Key Environment Variable Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/anthropic-api-setup.md This snippet demonstrates how to set the ANTHROPIC_API_KEY environment variable, which is necessary for the AI Infrastructure Agent to authenticate with the Anthropic API. It can be added to shell profiles for persistence or set temporarily for a single session. ```bash # Add to your shell profile (.bashrc, .zshrc, etc.) export ANTHROPIC_API_KEY="sk-ant-your-api-key-here" # Or set it temporarily for the current session export ANTHROPIC_API_KEY="sk-ant-your-api-key-here" ``` -------------------------------- ### Discover VPC, Subnets, and Availability Zones in Go Source: https://context7.com/versuscontrol/ai-infrastructure-agent/llms.txt This Go code snippet demonstrates how to discover and manage Virtual Private Cloud (VPC), subnets, and availability zones using the ai-infrastructure-agent's AWS client. It requires AWS credentials and the specified Go packages for execution. The output includes details about the default VPC, default subnet, all subnets within a VPC, and available availability zones. ```go package main import ( "context" "log" "github.com/versus-control/ai-infrastructure-agent/pkg/aws" "github.com/versus-control/ai-infrastructure-agent/internal/logging" ) func main() { ctx := context.Background() logger := logging.NewLogger("info", "text") client, _ := aws.NewClient("us-west-2", logger) // Get default VPC (with fallback to first available) vpcID, err := client.GetDefaultVPC(ctx) if err != nil { log.Fatalf("Failed to get VPC: %v", err) } log.Printf("Using VPC: %s", vpcID) // Get default subnet with VPC information subnetInfo, err := client.GetDefaultSubnet(ctx) if err != nil { log.Fatalf("Failed to get subnet: %v", err) } log.Printf("Default subnet: %s in VPC: %s", subnetInfo.SubnetID, subnetInfo.VpcID) // Get all subnets in VPC subnets, err := client.GetSubnetsInVPC(ctx, vpcID) if err != nil { log.Fatalf("Failed to list subnets: %v", err) } log.Printf("Found %d subnets in VPC %s", len(subnets), vpcID) for i, subnet := range subnets { log.Printf(" Subnet %d: %s", i+1, subnet) } // Get availability zones azs, err := client.GetAvailabilityZones(ctx) if err != nil { log.Fatalf("Failed to get AZs: %v", err) } log.Printf("Available zones in %s: %v", client.GetRegion(), azs) } ``` -------------------------------- ### Integrate MCP Server with Go Source: https://context7.com/versuscontrol/ai-infrastructure-agent/llms.txt This Go code sets up and runs an MCP (Model Context Protocol) server for AI agent communication. It handles signal processing for graceful shutdown, loads configuration, initializes an AWS client, and starts the MCP server. Dependencies include 'context', 'log', 'os', 'os/signal', 'syscall', 'config', 'logging', 'aws', and 'mcp' packages. ```go package main import ( "context" "log" "os" "os/signal" "syscall" "github.com/versus-control/ai-infrastructure-agent/internal/config" "github.com/versus-control/ai-infrastructure-agent/internal/logging" "github.com/versus-control/ai-infrastructure-agent/pkg/aws" "github.com/versus-control/ai-infrastructure-agent/pkg/mcp" ) func main() { // Setup signal handling ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) defer cancel() // Load configuration cfg, err := config.Load() if err != nil { log.Fatalf("Failed to load configuration: %v", err) } logger := logging.NewLogger("info", "text") // Initialize AWS client awsClient, err := aws.NewClient(cfg.AWS.Region, logger) if err != nil { log.Fatalf("Failed to initialize AWS client: %v", err) } // Verify AWS connectivity if err := awsClient.HealthCheck(ctx); err != nil { log.Fatalf("AWS health check failed: %v", err) } // Create MCP server with all components mcpServer := mcp.NewServer(cfg, awsClient, logger) logger.Info("Starting MCP server on stdio...") // Start server (blocks until shutdown signal) if err := mcpServer.Start(ctx); err != nil && err != context.Canceled { log.Fatalf("Server failed: %v", err) } logger.Info("MCP server shutdown complete") } ``` -------------------------------- ### Check Bedrock Monthly Usage with AWS CLI Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/aws-bedrock-nova-setup.md This AWS CLI command retrieves the monthly cost and usage for Amazon Bedrock. It specifies a time period, granularity, metric, and groups the results by service, filtering for 'Amazon Bedrock'. ```bash aws ce get-cost-and-usage \ --time-period Start=2024-01-01,End=2024-01-31 \ --granularity MONTHLY \ --metrics BlendedCost \ --group-by Type=DIMENSION,Key=SERVICE \ --query 'ResultsByTime[0].Groups[?Keys[0]==`Amazon Bedrock`]' ``` -------------------------------- ### SSH into EC2 Instance Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/examples/working-with-ec2-instance.md Connect to your provisioned EC2 instance using SSH. Ensure you have the correct private key file path and the instance's public IP address. The first-time connection requires confirmation of the host's authenticity. ```bash ssh -i ~/.ssh/apache-key-pair.pem ec2-user@ ``` -------------------------------- ### AWS IAM Policy Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md This JSON defines an AWS IAM policy that grants broad permissions for EC2, VPC, IAM, Elastic Load Balancing, and Auto Scaling. This policy is intended for an IAM user or role that needs extensive control over these AWS services. ```json { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "ec2:*", "vpc:*", "iam:PassRole", "elasticloadbalancing:*", "autoscaling:*" ], "Resource": "*" } ] } ``` -------------------------------- ### Configure AWS CLI Credentials for AI Infrastructure Agent Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/installation.md Configures AWS CLI credentials either interactively or by setting environment variables for region, access key ID, and secret access key. This is required when using AWS services like Bedrock. ```bash # Configure AWS CLI (interactive) aws configure # Or set environment variables export AWS_ACCESS_KEY_ID="your-access-key-id" export AWS_SECRET_ACCESS_KEY="your-secret-access-key" export AWS_DEFAULT_REGION="us-west-2" ``` -------------------------------- ### Configure AI Infrastructure Agent for Remote Ollama Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/ollama-setup.md Configures the AI Infrastructure Agent to connect to a remote Ollama server. This involves specifying the `ollama_server_url` in the agent's configuration file, pointing to the IP address and port of the remote Ollama instance. ```yaml agent: provider: "ollama" ollama_server_url: "http://your-server-ip:11434" # Remote Ollama server model: "gemma3:27b" max_tokens: 8192 temperature: 0.1 ``` -------------------------------- ### Test Nova Model Access Across Regions (Bash) Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/aws-bedrock-nova-setup.md This script tests the availability of Nova foundation models in different AWS regions by listing them and filtering for 'nova'. It's useful for verifying regional access and identifying potential model availability issues. ```bash # Test model access in different regions aws bedrock list-foundation-models --region us-east-1 | grep nova aws bedrock list-foundation-models --region us-west-2 | grep nova aws bedrock list-foundation-models --region eu-west-1 | grep nova aws bedrock list-foundation-models --region ap-southeast-1 | grep nova ``` -------------------------------- ### Recover from Missing Prerequisites Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/settings/templates/recovery-prompt-optimized.txt This pattern handles failures when a step depends on resources that have not yet been created. It defines steps to create the missing prerequisites, followed by a retry of the original failed step, ensuring that the retry step depends on the successful creation of all prerequisites. ```json { "recoverySteps": [ { "id": "step-create-", "action": "create", "mcpTool": "", "toolParameters": {"": "{{completed-step-id.}}"}, "dependsOn": [""] }, { "id": "step-create-", "action": "create", "mcpTool": "", "toolParameters": {"": "{{completed-step-id.}}"}, "dependsOn": [""] }, { "id": "-retry", "action": "create", "mcpTool": "", "toolParameters": { "": "{{step-create-.}}", "": "{{step-create-.}}" }, "dependsOn": ["step-create-", "step-create-"] } ], "adjustedRemainingSteps": [ /* Include ALL remaining steps, updating dependencies to reference retry step */ ] } ``` -------------------------------- ### Prompt Engineering for Instance Type Specification Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/examples/working-with-ec2-instance.md Specifies how to explicitly define the instance type and size for an EC2 instance. This ensures that the created instance meets performance and cost requirements, as different instance types have varying capabilities. ```text # Instead of this: Create an EC2 instance for Apache # Use this: Create a t3.medium EC2 instance for Apache Server ``` -------------------------------- ### Configure AI Infrastructure Agent for Anthropic Claude Source: https://github.com/versuscontrol/ai-infrastructure-agent/blob/main/docs/api-key-setup/anthropic-api-setup.md This snippet shows the YAML configuration for the AI Infrastructure Agent to use Anthropic's Claude models. It includes specifying the provider, the recommended model (claude-sonnet-4-5-20250929), maximum tokens, and temperature. This configuration can be placed in a config.yaml file. ```yaml agent: provider: "anthropic" model: "claude-sonnet-4-5-20250929" # Recommended max_tokens: 4000 temperature: 0.1 ```