# AGENTS.md — Build guide for TeamViewer

## Project scope
Build a personal remote-access prototype for machines the owner controls using WebRTC and an authenticated signaling service. Require visible host consent, a stop control and explicit enablement of keyboard/mouse input.

Catalogue verdict: kinda. If you only need to reach your own machines, most of TeamViewer's value is reproducible: screen capture, a WebRTC pipe, and synthetic mouse and keyboard events are all solved problems with libraries. An agent can wire that into a working host agent plus browser viewer in a weekend, and on your own LAN it will feel fine. What breaks is everything outside your control: connecting through hostile double NAT without your own TURN server, waking a sleeping box, keeping latency sane over mobile networks, and surviving OS permission prompts on macOS after every update. It also stops being a support tool, because the whole point of TeamViewer for helping your parents is that they can install one thing and read you a nine digit number. Build it for your own boxes, keep paying if you support other people's.
Use the implementation prompt below to define the deliverable. Complete each phase's acceptance checks before extending the scope.

## Working agreement
- Inspect the repository and its existing instructions before choosing paths, dependencies or commands. Keep one coherent stack and explain changes to the proposed architecture.
- Plan a vertical slice that accepts a real input and produces the useful output described below. Persist only the state the prompt calls for; respect memory-only and upstream-managed workflows. Use fixtures only when they are clearly labelled.
- After scaffolding, document the actual install, development, check and build commands in README and keep them synchronized with the package or project manifest. Do not report commands as successful unless they ran.
- Work in small steps. At handoff, list implemented flows, checks actually performed, remaining blockers, and any credentials or provider setup the owner must supply.
- Do not publish, spend money, contact customers, delete source data or run irreversible migrations without the project owner's authorization.

## Prerequisites
- Machines the operator owns, a selected supported OS capture/input implementation, HTTPS signaling and documented STUN/TURN configuration when needed. Prototype read-only screen streaming before enabling control.
- Implementation components: A TypeScript host agent and authenticated WebSocket signaling service with a static browser viewer. A selected WebRTC transport and documented OS capture/input adapters, with short-lived pairing/session grants and encrypted transport.
- Scope boundary: Cross-platform host capture, NAT traversal and secure unattended access require separate implementation and review.

## Stack and architecture
- A TypeScript host agent and authenticated WebSocket signaling service with a static browser viewer.
- A selected WebRTC transport and documented OS capture/input adapters, with short-lived pairing/session grants and encrypted transport.
- Domain model: owned host devices, pairing grants, authenticated sessions, stream negotiation, input events and revocation records

## Security and data integrity
- Use separate host pairing and viewer session credentials, validate signaling participants and require visible host approval. Ignore input from expired sessions and provide a local emergency stop.
- Correctness boundary: Session tokens are short-lived and bound to a paired device; a disconnected or revoked viewer cannot inject input, and there is no covert persistence.
- Bind stream/input channels to the approved session, bound buffering and discard stale input after reconnect. Coordinate mapping uses the active captured-display size. Losing authorization or transport stops control rather than replaying queued input.
- Persist pairing configuration without session secrets; a process crash revokes active control rather than silently reconnecting a viewer. Export operator diagnostics without screen contents.

## Agent implementation rules
- Project rule — data model: owned host devices, pairing grants, authenticated sessions, stream negotiation, input events and revocation records
- Project rule — preserve this invariant: Session tokens are short-lived and bound to a paired device; a disconnected or revoked viewer cannot inject input, and there is no covert persistence.
- Project rule — acceptance evidence: Revoke the viewer during a session and stop input immediately; a reconnect requires valid authorization and no screen is shared before host approval.

## Optional agent skills and references
- Optional external skill: [sharp-edges](https://github.com/trailofbits/skills/blob/main/plugins/sharp-edges/skills/sharp-edges/SKILL.md) — Review security-sensitive APIs and configuration for dangerous defaults and easy-to-misuse interfaces. Review its instructions and compatibility before use; it does not grant deployment, data-access or publication permission.
- Optional external skill: [agent-browser](https://github.com/vercel-labs/agent-browser/blob/main/skills/agent-browser/SKILL.md) — Automate browser interaction using accessibility snapshots, element references and reproducible navigation workflows. Review its instructions and compatibility before use; it does not grant deployment, data-access or publication permission.

Read the linked SKILL.md and its dependencies before adding a skill. Select only the skills matching this project's runtime and task; their documentation does not supply API access, credentials or approval to perform external actions. Pin the reviewed revision where the tool supports it. Follow the chosen agent's documented project-level installation mechanism.

## Distribution ideas
These are optional planning notes. Obtain the owner's approval before publishing or contacting anyone.
- Demonstrate the actual TeamViewer-inspired workflow with owned or clearly labeled sample data: Build a personal remote-access prototype for machines the owner controls using WebRTC and an authenticated signaling service. Require visible host consent, a stop control and explicit enablement of keyboard/mouse input.
- Publish a reproducible walkthrough with this observable result: Revoke the viewer during a session and stop input immediately; a reconnect requires valid authorization and no screen is shared before host approval.
- Explain who can operate this scoped tool, its setup and ongoing costs, and these remaining product gaps: Cross-platform host capture, NAT traversal and secure unattended access require separate implementation and review. Avoid guaranteed savings, performance scores or implied endorsement.

## Engineering roadmap
1. Phase 1 — Scope and fixtures. Implement this bounded workflow: Build a personal remote-access prototype for machines the owner controls using WebRTC and an authenticated signaling service. Require visible host consent, a stop control and explicit enablement of keyboard/mouse input. Record prerequisites, select representative user-owned fixtures and document the unsupported features: Cross-platform host capture, NAT traversal and secure unattended access require separate implementation and review.
2. Phase 2 — Durable model. Model owned host devices, pairing grants, authenticated sessions, stream negotiation, input events and revocation records Add migrations or a versioned document format, explicit validation, stable IDs and a visible import-error report. Preserve this rule: Session tokens are short-lived and bound to a paired device; a disconnected or revoked viewer cannot inject input, and there is no covert persistence.
3. Phase 3 — Complete the first useful path. Implement the workflow's input, review and output interface, with clear controls and explicit empty/error states. Bind stream/input channels to the approved session, bound buffering and discard stale input after reconnect. Coordinate mapping uses the active captured-display size. Losing authorization or transport stops control rather than replaying queued input.
4. Phase 4 — Permissions and integration failure. Use separate host pairing and viewer session credentials, validate signaling participants and require visible host approval. Ignore input from expired sessions and provide a local emergency stop. Request integration credentials and permissions only for the enabled feature; show a disconnected state instead of mock results.
5. Phase 5 — Portable handoff. Persist pairing configuration without session secrets; a process crash revokes active control rather than silently reconnecting a viewer. Export operator diagnostics without screen contents. Include setup, operating limits, fixture walkthrough and shutdown/restart instructions in the README.
6. Phase 6 — Acceptance scenarios. Revoke the viewer during a session and stop input immediately; a reconnect requires valid authorization and no screen is shared before host approval. Repeat the workflow after restart and with a denied permission or unavailable dependency; show recoverable failure rather than a success placeholder.

## Paid-product capabilities outside this build
- Connections that just work through carrier grade NAT, corporate firewalls, and proxies without you operating relay infrastructure
- Native clients for Windows, macOS, Linux, iOS, and Android, plus mobile device support
- The support workflow: a one-click download and a session code a non-technical person can read to you over the phone
- Unattended access extras: wake on LAN, reboot and reconnect, multi-monitor switching, file transfer, session recording, printing
- Commercial licensing, audit logs, and the corporate compliance story that makes IT allow it at all

## Implementation prompt
WORKING SLICE
Build a personal remote-access prototype for machines the owner controls using WebRTC and an authenticated signaling service. Require visible host consent, a stop control and explicit enablement of keyboard/mouse input.

Build this scoped TeamViewer-inspired workflow with a documented data model and visible failure states.

Architecture
- A TypeScript host agent and authenticated WebSocket signaling service with a static browser viewer.
- A selected WebRTC transport and documented OS capture/input adapters, with short-lived pairing/session grants and encrypted transport.

Prerequisites and limits
Machines the operator owns, a selected supported OS capture/input implementation, HTTPS signaling and documented STUN/TURN configuration when needed. Prototype read-only screen streaming before enabling control.
Outside this release: Cross-platform host capture, NAT traversal and secure unattended access require separate implementation and review.

Data model and correctness
owned host devices, pairing grants, authenticated sessions, stream negotiation, input events and revocation records
Invariant: Session tokens are short-lived and bound to a paired device; a disconnected or revoked viewer cannot inject input, and there is no covert persistence.
Bind stream/input channels to the approved session, bound buffering and discard stale input after reconnect. Coordinate mapping uses the active captured-display size. Losing authorization or transport stops control rather than replaying queued input.

Security and privacy
Use separate host pairing and viewer session credentials, validate signaling participants and require visible host approval. Ignore input from expired sessions and provide a local emergency stop.

Recovery and export
Persist pairing configuration without session secrets; a process crash revokes active control rather than silently reconnecting a viewer. Export operator diagnostics without screen contents.

Implementation order
1. Phase 1 — Scope and fixtures. Implement this bounded workflow: Build a personal remote-access prototype for machines the owner controls using WebRTC and an authenticated signaling service. Require visible host consent, a stop control and explicit enablement of keyboard/mouse input. Record prerequisites, select representative user-owned fixtures and document the unsupported features: Cross-platform host capture, NAT traversal and secure unattended access require separate implementation and review.
2. Phase 2 — Durable model. Model owned host devices, pairing grants, authenticated sessions, stream negotiation, input events and revocation records Add migrations or a versioned document format, explicit validation, stable IDs and a visible import-error report. Preserve this rule: Session tokens are short-lived and bound to a paired device; a disconnected or revoked viewer cannot inject input, and there is no covert persistence.
3. Phase 3 — Complete the first useful path. Implement the workflow's input, review and output interface, with clear controls and explicit empty/error states. Bind stream/input channels to the approved session, bound buffering and discard stale input after reconnect. Coordinate mapping uses the active captured-display size. Losing authorization or transport stops control rather than replaying queued input.
4. Phase 4 — Permissions and integration failure. Use separate host pairing and viewer session credentials, validate signaling participants and require visible host approval. Ignore input from expired sessions and provide a local emergency stop. Request integration credentials and permissions only for the enabled feature; show a disconnected state instead of mock results.
5. Phase 5 — Portable handoff. Persist pairing configuration without session secrets; a process crash revokes active control rather than silently reconnecting a viewer. Export operator diagnostics without screen contents. Include setup, operating limits, fixture walkthrough and shutdown/restart instructions in the README.
6. Phase 6 — Acceptance scenarios. Revoke the viewer during a session and stop input immediately; a reconnect requires valid authorization and no screen is shared before host approval. Repeat the workflow after restart and with a denied permission or unavailable dependency; show recoverable failure rather than a success placeholder.

Acceptance
Revoke the viewer during a session and stop input immediately; a reconnect requires valid authorization and no screen is shared before host approval.
Use real source data or clearly labeled fixtures. Explain unsupported input and provider failures; do not fabricate analytics, delivery receipts, accuracy claims or security guarantees.

Optional agent guidance
Optional external skill: [sharp-edges](https://github.com/trailofbits/skills/blob/main/plugins/sharp-edges/skills/sharp-edges/SKILL.md) — Review security-sensitive APIs and configuration for dangerous defaults and easy-to-misuse interfaces. Review its instructions and compatibility before use; it does not grant deployment, data-access or publication permission.
Optional external skill: [agent-browser](https://github.com/vercel-labs/agent-browser/blob/main/skills/agent-browser/SKILL.md) — Automate browser interaction using accessibility snapshots, element references and reproducible navigation workflows. Review its instructions and compatibility before use; it does not grant deployment, data-access or publication permission.
Project rule — data model: owned host devices, pairing grants, authenticated sessions, stream negotiation, input events and revocation records
Project rule — preserve this invariant: Session tokens are short-lived and bound to a paired device; a disconnected or revoked viewer cannot inject input, and there is no covert persistence.
Project rule — acceptance evidence: Revoke the viewer during a session and stop input immediately; a reconnect requires valid authorization and no screen is shared before host approval.

## Completion evidence
Demonstrate the prompt's acceptance scenarios against the scoped workflow. Include setup from a clean checkout and failure recovery. Check persistence across restart and export/restore only for the state the prompt says to store; for memory-only tools, confirm that temporary content is discarded as specified. Record actual results and remaining limitations. A detailed plan alone does not establish a working replacement.
