Backend for Raider VS Code Extension
Project description
Raider Backend Repository
This repository contains the implementation of the Raider Backend, a system designed to manage and interact with various agents for code analysis and task management.
Table of Contents
Overview
The Raider Backend system is designed to manage multiple agents that can perform various tasks such as running code, generating subtasks, and managing external repositories. The system is built using Python and provides both synchronous and asynchronous functionalities.
Directory Structure
raider_backend/
: Main directory containing the core functionalities.__init__.py
: Initializes theraider_backend
package.agent_manager.py
: Manages the overall process and agents.launch.py
: Launches the LaunchConnectionManager with a WebSocket endpoint.logger.py
: Configures logging for the application.parse.py
: Provides functionality to parse source code files and extract class, method, and function definitions using the tree-sitter library.planner_agent.py
: Manages the planning process for a given objective.prompts.py
: Contains prompt templates used by the agents for various tasks.repo_agent.py
: Defines BaseRepoAgent, ExternalRepoAgent, and MainRepoAgent classes.utils.py
: Utility functions for various tasks.connection_managers/
: Directory for connection management classes.base_connection_manager.py
: Defines the BaseConnectionManager class.agent_manager_connection_manager.py
: Implements the AgentManagerConnectionManager.launch_connection_manager.py
: Implements the LaunchConnectionManager.web_raider_connection_manager.py
: Implements the WebRaiderConnectionManager.
handlers/
: Directory for handler classes.base_handler.py
: Defines the BaseHandler class.agent_manager_handler.py
: Implements the AgentManagerHandler.external_repo_agent_handler.py
: Implements the ExternalRepoAgentHandler.
Installation
You can install the raider_backend package directly from PyPI using pip:
pip install raider_backend
This command will automatically download and install the latest version of raider_backend along with its dependencies.
For developers who want to work on the raider_backend codebase:
-
Clone the repository:
git clone https://github.com/sikfeng/raider-backend.git cd raider-backend
-
Install the package in editable mode:
pip install -e .
This command installs the package in editable mode (-e), which is useful for development as it allows you to modify the source code and immediately see the effects without reinstalling.
-
(Optional) Build the Docker image:
./build_docker.sh
After installation, you can import and use the raider_backend package in your Python scripts or interactive sessions.
Usage
To run the main application, execute:
launch_endpoint
The usage information is as follows:
usage: launch_endpoint [-h] [--port PORT] [--logfile LOGFILE]
Launch the AgentManager with a Websocket endpoint.
options:
-h, --help show this help message and exit
--port PORT Port of the websocket (default: 10000)
--logfile LOGFILE Path to logfile (default: /tmp/manager.log)
Running in a Devcontainer
-
Open the repository in Visual Studio Code:
- Ensure you have the Remote - Containers extension installed.
-
Reopen in Container:
- Click on the green button in the bottom-left corner of the VS Code window.
- Select
Reopen in Container
.
-
Post Start Command:
- After the container starts, the
postStartCommand
defined in.devcontainer/devcontainer.json
will automatically install the necessary dependencies.
- After the container starts, the
Note: The devcontainer will only mount the parent directory of this repository as the VS Code workspace. Therefore, the repository you are working on and any repository you want to use as context must be within the parent directory of the current repository.
Environment Variables: You can add environment variables such as API keys to the .env
file within the .devcontainer
directory. This will ensure that these variables are available within the development container.
This will set up the development environment inside a Docker container, ensuring consistency across different development setups.
API Endpoints
The system provides WebSocket endpoints for interacting with the agents:
1. Agent Manager Endpoint
-
WebSocket Endpoint:
ws://<host>:<port>/ws/{session_id}
This endpoint is managed by the
AgentManagerConnectionManager
, which acts as an intermediary between the external client and theAgentManager
.When sending messages to this endpoint, use the following JSON format:
{ "method": "<method_name>", "params": { "<param1>": "<value1>", "<param2>": "<value2>", ... } }
Available methods include:
-
init_external_repo_agent
: Initializes an external repository agent.- Params:
repo_dir
(str): The directory of the repository.model_name
(str, optional): The name of the model to use. Default is "azure/gpt-4o".timeout
(int, optional): Timeout for agent initialization. Default is 10 seconds.
- Params:
-
get_external_repo_agents
: Retrieves a list of external repository agents. -
generate_subtasks
: Generates subtasks for a given objective.- Params:
objective
(str): The main objective.
- Params:
-
run_subtask
: Runs a specified subtask.- Params:
subtask
(str): The subtask to run.
- Params:
-
generate_commands
: Generates commands for a given subtask.- Params:
subtask
(str): The subtask for which to generate commands.
- Params:
-
undo
: Undoes the last commit. -
shutdown
: Shuts down the AgentManager. -
disable_external_repo_agent
: Disables an external repository agent.- Params:
agent_id
(str): The ID of the agent to disable.
- Params:
-
enable_external_repo_agent
: Enables a previously disabled external repository agent.- Params:
agent_id
(str): The ID of the agent to enable.
- Params:
-
Example
To initialize an external repository agent, the data format would be:
{
"main_repo_dir": "/path/to/main/repo",
"method": "init_external_repo_agent",
"params": {
"repo_dir": "/path/to/external/repo",
"model_name": "azure/gpt-4o",
"timeout": 15
}
}
The LaunchConnectionManager
will process this request, forward it to the appropriate AgentManagerHandler
, and return the response through the WebSocket connection.
2. Web Raider Endpoint
-
WebSocket Endpoint:
ws://<host>:<port>/web_raider/ws/{session_id}
This endpoint is managed by the
WebRaiderConnectionManager
, which handles queries for the Web Raider functionality.When sending messages to this endpoint, use the following JSON format:
{ "method": "query", "params": { "user_query": "<your_query>" } }
Available methods:
query
: Sends a query to the Web Raider pipeline.- Params:
user_query
(str): The query to be processed by Web Raider.
- Params:
Example
To send a query to Web Raider, the data format would be:
{
"method": "query",
"params": {
"user_query": "Find a programming language agnostic AST parser"
}
}
The WebRaiderConnectionManager
will process this request, forward it to the Web Raider pipeline, and return the response through the WebSocket connection.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file raider_backend-0.0.2.tar.gz
.
File metadata
- Download URL: raider_backend-0.0.2.tar.gz
- Upload date:
- Size: 27.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.0 Linux/6.11.2-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | c1ed253addb62db986d5a66a0fe14f43634b40b19d4ebca996516348ae2c71d1 |
|
MD5 | b03bbf7eb1bef8a4a220becbec8a3660 |
|
BLAKE2b-256 | d3751bfa3963ff32f663ed4706af8dcbe6bf599de5132830632e1bac59c17d89 |
File details
Details for the file raider_backend-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: raider_backend-0.0.2-py3-none-any.whl
- Upload date:
- Size: 34.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.8.3 CPython/3.11.0 Linux/6.11.2-arch1-1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0dac1c884c8a755d2361faa19d2834076f847ede135ff75d3672dee08b451f5f |
|
MD5 | cebb0f79e974eb2ef0c4f4a59c9257a7 |
|
BLAKE2b-256 | 489f9e49746da2fbe5480716745e82426de00306aa32e6744a0f25ba5a6c62f7 |