# GhostFoundry-Syndicate Local Agent

This agent enables autonomous operations on your local machine, controlled via Telegram or the Ghost Control Dashboard.

## Features

- 🔄 **Remote Command Execution**: Execute commands on your machine from anywhere
- 🚀 **Automated Deployments**: Trigger deployments via Telegram
- 🔐 **Secure Authentication**: Token-based authentication
- 📊 **Status Monitoring**: Check system status remotely

## Quick Start

### 1. Generate Agent Token

Go to Ghost Control Dashboard > Settings > Local Agent and generate a token.

### 2. Configure

Create a `.env` file:

```bash
GFS_SERVER_URL=https://spookysoftwaresyndicate.com
GFS_AGENT_TOKEN=your_token_here
GFS_POLL_INTERVAL=5000
```

### 3. Install Dependencies

```bash
npm install
```

### 4. Run

```bash
npm start
```

## Available Commands

| Command | Description |
|---------|-------------|
| `ping` | Test connectivity |
| `status` | Agent status |
| `system_info` | System information |
| `git_status` | Git repository status |
| `git_pull` | Pull latest changes |
| `npm_install` | Install npm dependencies |
| `yarn_install` | Install yarn dependencies |
| `deploy` | Full deployment workflow |
| `run_script` | Run custom scripts |

## Security

- Agent only executes whitelisted commands
- All communication is token-authenticated
- Commands are logged for audit

## Running as a Service

### Linux (systemd)

Create `/etc/systemd/system/gfs-agent.service`:

```ini
[Unit]
Description=GFS Local Agent
After=network.target

[Service]
Type=simple
WorkingDirectory=/path/to/local-agent
ExecStart=/usr/bin/node agent.js
Restart=always
Environment=GFS_SERVER_URL=https://spookysoftwaresyndicate.com
Environment=GFS_AGENT_TOKEN=your_token

[Install]
WantedBy=multi-user.target
```

Then:
```bash
sudo systemctl enable gfs-agent
sudo systemctl start gfs-agent
```

### macOS (launchd)

Create `~/Library/LaunchAgents/com.gfs.agent.plist` and load with:
```bash
launchctl load ~/Library/LaunchAgents/com.gfs.agent.plist
```

### Windows

Use `node-windows` package or Windows Task Scheduler.
