A flexible Python-based agent framework for automated tasks. Currently includes the ai-deploy agent for synchronizing files between different locations.
- Modular Agent Architecture: Easy to extend with new agent types
- Multiple Connection Types: Support for Windows shares and SSH/SFTP
- Flexible Authentication: Password or SSH key-based authentication
- Intelligent File Comparison: Detects new, modified, and deleted files
- Flexible Ignore Patterns: Exclude files, folders, or extensions
- Dry Run Mode: Preview changes before applying them
- Detailed Logging: Track all operations and errors
aiagent/
├── agents/ # Agent implementations
│ └── ai_deploy.py # File deployment/sync agent
├── core/ # Core framework classes
│ ├── agent_base.py # Base class for all agents
│ └── config_loader.py # Configuration loading utilities
├── handlers/ # Connection handlers
│ ├── windows_share_handler.py # Windows network share handler
│ └── ssh_handler.py # SSH/SFTP handler
├── config/ # Configuration examples
│ ├── ai-deploy-example-windows.json
│ ├── ai-deploy-example-ssh-password.json
│ ├── ai-deploy-example-ssh-key.json
│ └── ai-deploy-example-dry-run.json
├── main.py # Main entry point
├── requirements.txt # Python dependencies
└── README.md # This file
- Clone or download this repository
- Install dependencies:
pip install -r requirements.txtThe ai-deploy agent synchronizes files from a source location to a destination location, making the destination match the source.
- Compare source and destination files
- Copy new files
- Update modified files (based on size and modification time)
- Delete extra files from destination (optional)
- Ignore specific files, folders, or extensions
- Dry run mode for testing
Create a JSON configuration file with the following structure:
{
"agent_name": "ai-deploy",
"description": "Description of this deployment",
"source": {
"type": "windows_share|ssh",
...
},
"destination": {
"type": "windows_share|ssh",
...
},
"ignore": {
"files": ["*.log", "*.tmp"],
"folders": ["__pycache__", ".git"],
"extensions": [".pyc", ".bak"]
},
"options": {
"dry_run": false,
"delete_extra_files": true
}
}{
"type": "windows_share",
"path": "\\\\server\\share\\folder",
"username": "DOMAIN\\username", // Optional
"password": "password" // Optional
}Or for local paths:
{
"type": "windows_share",
"path": "C:\\path\\to\\folder"
}With password authentication:
{
"type": "ssh",
"host": "server.example.com",
"port": 22,
"username": "user",
"password": "password",
"path": "/remote/path"
}With key-based authentication:
{
"type": "ssh",
"host": "server.example.com",
"port": 22,
"username": "user",
"key_file": "/path/to/private/key",
"path": "/remote/path"
}{
"ignore": {
"files": [
"*.log",
"*.tmp",
".env"
],
"folders": [
"__pycache__",
".git",
"node_modules",
".venv"
],
"extensions": [
".pyc",
".pyo",
".bak"
]
}
}dry_run: Iftrue, shows what would be done without making changesdelete_extra_files: Iftrue, deletes files from destination that don't exist in source
Run the agent with a configuration file:
python main.py config/ai-deploy-example-windows.jsonOr explicitly specify the agent type:
python main.py --agent-type ai-deploy config/my-config.jsonpython main.py config/ai-deploy-example-ssh-password.jsonpython main.py config/ai-deploy-example-windows.jsonpython main.py config/ai-deploy-example-dry-run.jsonSeveral example configurations are provided in the config/ directory:
ai-deploy-example-windows.json- Windows share to Windows shareai-deploy-example-ssh-password.json- Local to SSH with passwordai-deploy-example-ssh-key.json- SSH to SSH with key authenticationai-deploy-example-dry-run.json- Dry run example
To create a new agent:
- Create a new class in
agents/that inherits fromAgentBase - Implement
_validate_config()andrun()methods - Add the agent to
agents/__init__.py - Update
main.pyto support the new agent type
Example:
from core.agent_base import AgentBase
class MyNewAgent(AgentBase):
def _validate_config(self, config):
# Validate your configuration
pass
def run(self):
# Implement your agent logic
pass- Python 3.7+
- paramiko (for SSH connections)
- Configuration files may contain sensitive credentials
- Use key-based authentication when possible
- Store configuration files securely
- Consider using environment variables for credentials
- Be cautious with the
delete_extra_filesoption
This project is provided as-is for educational and commercial use.
Feel free to extend this framework with new agents and handlers!