# Module: Nexus Agent

**Placering:** `source/nexus-agent/`  
**Fase:** 1 (skeleton) → 4 (fuld)  
**Type:** Windows Service (client)

---

## Funktioner

- Enhedsregistrering og heartbeat
- Hardware/software/OS-inventar indsamling
- Policy engine (modtag, anvend, verificer, rapportér)
- Software installation og opdatering
- Remote support tunnel (WebRTC)
- Lokal data-cache (SQLite, encrypted)
- Device certificate management (TPM)
- IPC server for Shell-kommunikation

---

## Ansvar

| Ansvar | Ejer |
|--------|------|
| Cloud-kommunikation (mTLS) | Agent |
| Policy enforcement på enhed | Agent |
| Inventar indsamling | Agent |
| Software install/uninstall | Agent |
| Offline queue og sync | Agent |
| Lokal IPC for Shell | Agent |

---

## Datamodel (lokal SQLite)

```
AgentState
├── device_id: UUID
├── certificate_thumbprint: string
├── last_sync_at: timestamp
├── network_status: online|degraded|offline

PolicyCache
├── policy_id: UUID
├── version: integer
├── definition: JSON
├── applied_at: timestamp
├── compliance_status: string

SyncQueue
├── id: UUID
├── type: string
├── payload: JSON
├── created_at: timestamp
├── retry_count: integer

InventoryCache
├── category: string
├── data: JSON
├── captured_at: timestamp
```

---

## Afhængigheder

| Afhænger af | Hvorfor |
|-------------|---------|
| Control Center API | Kommandoer, politikker, registrering |
| Windows OS | WMI, registry, services, TPM |

| Afhænges af af | Hvorfor |
|----------------|---------|
| Nexus Shell | Status, policy-resultater, app-install |
| Device Management | Inventar, compliance |
| Update Service | Pakke-download og install |
| Remote Support | Tunnel, screen capture |

---

*Se: [architecture/CLIENT_SERVER_ARCHITECTURE.md](../architecture/CLIENT_SERVER_ARCHITECTURE.md)*
