# RemoteLink Agent

The RemoteLink Agent is an Electron-based desktop application that enables remote desktop control. It runs in the system tray and allows users to generate session codes for remote access.

## Features

- System tray integration with quick access menu
- Session code generation (6-digit codes, 10-minute expiry)
- Screen capture using Electron's desktopCapturer
- WebRTC peer-to-peer connections
- Multi-monitor support
- Cross-platform (Windows, macOS, Linux)

## Development Setup

```bash
# Navigate to the agent directory
cd electron-agent

# Install dependencies
npm install

# Run in development mode
npm run dev
```

## Building

```bash
# Build for all platforms
npm run build
npm run package

# Platform-specific builds
npm run package:win   # Windows
npm run package:mac   # macOS
npm run package:linux # Linux
```

## Architecture

```
electron-agent/
├── src/
│   ├── main/           # Main process (Node.js)
│   │   └── index.ts    # Tray, IPC handlers, WebRTC
│   ├── preload/        # Preload scripts (bridge)
│   │   └── index.ts    # Exposes safe APIs to renderer
│   └── renderer/       # Renderer process (UI)
│       └── index.html  # Agent UI
├── assets/             # Icons and images
└── package.json
```

## Configuration

The agent needs to be configured with an access key from the RemoteLink web dashboard:

1. Register/login at the web dashboard
2. Navigate to Machines > Add Machine
3. Copy the generated access key
4. Paste it in the agent's setup screen

## API Endpoints

The agent communicates with these server endpoints:

- `POST /api/agent/register` - Register machine with server
- `POST /api/agent/heartbeat` - Maintain online status
- `POST /api/agent/session-code` - Generate session codes
- `POST /api/signal` - WebRTC signaling

## Security

- Access keys are unique per machine
- Session codes expire after 10 minutes
- All WebRTC connections are encrypted
- No screen data passes through servers (P2P)

## Input Simulation

For full remote control, the agent uses native libraries:

- **Windows**: `robotjs` or `nut.js`
- **macOS**: Requires Accessibility permissions
- **Linux**: X11 or Wayland protocols

Note: Input simulation is not implemented in this demo version.
