7.2 KiB
Discord-Linux Groq Agent
Table of Contents
- Overview
- Features
- Prerequisites
- Installation
- Configuration
- Usage
- Logging
- Troubleshooting
- Contributing
- License
Overview
Remote Container Manager is a Node.js script designed to automate the management of remote Debian/Ubuntu-based Linux containers. Leveraging AI-driven command generation and robust API integrations, this tool simplifies tasks such as package installation and service management by executing precise shell commands on remote containers.
Features
- AI-Powered Command Generation: Utilizes AI to generate shell commands based on your specified goals and context.
- Verbose Logging: Detailed and formatted logs make it easy to track the script's actions and outputs.
- API Integration: Connects seamlessly with Groq and Discord Linux APIs to execute commands remotely.
- Iterative Execution: Attempts to achieve the desired state through multiple iterations, refining commands based on previous outcomes.
- Environment Configuration: Easily manage API keys and other settings via environment variables.
Prerequisites
Before you begin, ensure you have met the following requirements:
- Node.js: Version 14.0 or higher. Download Node.js
- Git: For cloning the repository. Download Git
- API Access:
- Groq API Key
- Discord Linux API Key
Installation
-
Clone the Repository
git clone https://git.ssh.surf/snxraven/discord-linux-groq-agent.git cd discord-linux-groq-agent
-
Install Dependencies
Ensure you have Node.js installed. Then, install the required packages:
npm install
Configuration
-
Create Environment Variables
The script relies on environment variables for API keys and configurations. An example file named
default.env
is provided. Follow these steps to set up your environment variables:-
Copy the Example
.env
Filecp default.env .env
-
Edit the
.env
FileOpen the
.env
file in your preferred text editor and replace the placeholder values with your actual API keys.# .env DISCORD_LINUX_API_URL=https://api.ssh.surf DISCORD_LINUX_API_KEY=your_discord_linux_api_key GROQ_API_KEY=your_groq_api_key
-
Environment Variables Explained
Variable Description DISCORD_LINUX_API_URL
The base URL for the Discord Linux API. DISCORD_LINUX_API_KEY
Your API key for authenticating with Discord Linux. GROQ_API_KEY
Your Groq API key for AI-driven command generation.
-
Usage
To run the script, use the following command:
node agent.js
Example Goal:
const goal = 'install apache2 (apache2) on the container and run it with service';
Script Flow:
- Initialization: Sets up the Groq client and logs the starting process.
- AI Instruction Request: Sends the current context and goal to the AI to receive shell commands.
- Command Execution: Executes each command on the remote container, logging the output.
- Iteration: Repeats the process up to a maximum number of iterations (
MAX_ITERATIONS
) until the goal is achieved or attempts are exhausted.
Logging
The script features comprehensive and formatted logging to ensure transparency and ease of monitoring.
Log Components
- Headers: Clearly marked sections indicating the start of processes and iterations.
- Subheaders: Indicate specific actions like requesting AI instructions.
- Info Messages: Provide status updates on command execution success or failure.
- Command Execution Logs: Detailed output of each executed command, including
stdout
andstderr
.
Example Log Output:
════════════════════════════════════════════════════════════════════════════════════════
═ STARTING PROCESS TO ACHIEVE GOAL: install apache2 (apache2) on the container and run it with service
════════════════════════════════════════════════════════════════════════════════════════
════════════════════════════════════════════════════════════════════════════════════════
═ ITERATION 1 OF 5
════════════════════════════════════════════════════════════════════════════════════════
------------------------------------------------------------
> Asking AI for instructions
------------------------------------------------------------
AI PROVIDED COMMANDS:
sudo apt-get update
sudo apt-get install -y apache2
sudo service apache2 start
[EXECUTING COMMAND]
$ sudo apt-get update
[STDOUT]:
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
...
[STDERR]: (empty)
INFO: Command executed successfully.
...
SUCCESS! The goal appears to have been achieved.
Troubleshooting
If you encounter issues while running the script, consider the following steps:
-
Check Environment Variables:
- Ensure all required environment variables are set correctly in the
.env
file. - Verify that API keys are valid and have the necessary permissions.
- Ensure all required environment variables are set correctly in the
-
API Connectivity:
- Confirm that the
DISCORD_LINUX_API_URL
is correct and reachable. - Check your internet connection and any firewall settings that might block API requests.
- Confirm that the
-
Dependencies:
- Make sure all dependencies are installed by running
npm install
. - Verify that you're using a compatible Node.js version (14.0 or higher).
- Make sure all dependencies are installed by running
-
Script Errors:
- Review the console logs for specific error messages.
- Ensure that the remote container is accessible and configured correctly.
-
AI Command Accuracy:
- If the AI provides incorrect or ineffective commands, consider refining the
systemPrompt
or providing more context.
- If the AI provides incorrect or ineffective commands, consider refining the
Contributing
Contributions are welcome! Follow these steps to contribute:
-
Fork the Repository
-
Create a Feature Branch
git checkout -b feature/YourFeature
-
Commit Your Changes
git commit -m "Add your feature"
-
Push to the Branch
git push origin feature/YourFeature
-
Open a Pull Request
Please ensure your contributions adhere to the project's coding standards and include appropriate documentation.