Skip to content

Spec: Mobile device pairing and remote access to the Host #1644

Closed
2 of 2 issues completed
Closed

Description

@DoodleBears

Parent: #1643

Problem Statement

The only way to reach a running DSH Host from another device today is the per-process launch token: GET /?token= exchanges it for a signed cookie, and the token rotates on every Host restart (ADR-0159, docs/agents/phone-qa-tunnel.md). That is fine for an agent's QA session but unusable for a phone the Human carries every day: after any restart the phone is locked out until someone copies a new token from the computer, there is no way to see which devices have access, and no way to cut one device off without restarting everything.

Solution

The Human pairs a phone once by scanning a QR code shown on the computer. The phone then reconnects on its own, across Host restarts and network changes, for as long as the Human keeps it paired. The Human sees the list of paired devices with last-seen time and can revoke any one of them, which immediately ends that device's access. The Host stays loopback-bound; the phone reaches it through an authenticated route, Tailscale HTTPS first.

User Stories

  1. As the Human, I want to open a "Pair a phone" entry in the Web Client, so that I can start pairing without the command line.
  2. As the Human, I want the computer to show a QR code, so that I can pair by pointing the phone camera at it.
  3. As the Human, I want the QR code to expire after a short time and work only once, so that a photo of my screen cannot pair another device later.
  4. As the Human, I want a copyable pairing link as an alternative to the QR code, so that I can pair when the camera is not usable.
  5. As the Human, I want the pairing link to carry the route the phone should use, so that I do not type addresses on the phone.
  6. As the Human, I want the computer to warn me when it has no route a phone can reach (only loopback), so that I fix Tailscale before scanning.
  7. As the Human, I want pairing to offer my machine's Tailscale HTTPS address automatically when Tailscale is running, so that the common setup takes no configuration.
  8. As the Human, I want a paired phone to keep working after the Host restarts, so that I do not re-pair after every update or reboot.
  9. As the Human, I want each paired phone to appear in a "Paired devices" list with its name, pairing time and last-seen time, so that I know what can reach my computer.
  10. As the Human, I want to revoke one device, so that a lost phone loses access without affecting my other devices.
  11. As the Human, I want revocation to take effect immediately, including open live streams, so that a revoked phone cannot keep watching.
  12. As the Human, I want a device's credential to be stored only in the phone's secure storage (Keychain/Keystore), so that another app cannot read it.
  13. As the Human, I want the computer never to print the device credential in logs, diagnostics bundles or the CLI, so that support material does not leak access.
  14. As the Human, I want a clear refusal when a revoked or unknown device connects, so that the app can tell me to pair again instead of failing silently.
  15. As the Human, I want the paired phone to have the same authority as my Web Client, so that I can do on the phone what I do on the computer.
  16. As the Human, I want pairing and revocation recorded as developer diagnostics, so that an agent can debug "the phone can't connect" without guessing.
  17. As a BotHarness developer, I want the device credential to be accepted on the same carriers the Web Client and live CLI already use (HTTP unary /api/<method> and the Remote stream socket), so that the mobile app needs no second protocol.
  18. As a BotHarness developer, I want the live CLI to be able to use a paired-device credential instead of the rotating launch token, so that long-lived scripts stop breaking on restart.
  19. As the Human, I want the phone to keep a list of routes for one computer (Tailscale now, LAN and tunnel later) and use the first that answers, so that the same pairing works at home and outside.
  20. As the Human, I want plain-HTTP LAN routes refused for anything but loopback by default, so that my credential never crosses Wi-Fi unencrypted.

Implementation Decisions

  • Open architecture question first (time-boxed spike, then an ADR): how a paired device is admitted by DSH across restarts. DSH currently has one credential form (launch token → signed cookie). Candidates, in preference order:
    1. A DSH-native durable session or credential mechanism, if 0.2.x exposes one (verify against the pinned DSH, including whether signed cookies already survive restarts as the phone QA runbook observed).
    2. A BotHarness pairing service that holds a per-device secret and exchanges it on the Host for a DSH authority cookie through a supported DSH extension point.
    3. An upstream DSH contribution adding device credentials.
      A second listener or reverse-proxy gateway in front of dsh web is the fallback, not the default (ADR-0159 rejected new listeners as extra attack surface). The ADR must record which one and why.
  • Device Pairing is an application-defined Host module (one deep module) that owns: pairing offers (one-time, short-lived, single use), paired-device records (id, name, created, last seen, revoked), credential verification, revocation, and the route list offered to a device. The operational database is its persistence; secrets are stored hashed, never in config or the repo (ADR-0006 spirit).
  • Pairing payload is a URL usable as a QR code and as a deep link into the app: Host identity, one-time offer, ordered route list. The phone binds the paired credential to a device key it generates (t3code binds bootstrap credentials to a client DPoP key; adopt the same idea if the chosen admission path allows it).
  • Routes: v1 supports Tailscale HTTPS (*.ts.net, matching the live CLI's accepted origins) and loopback for development. The Host's trusted-host configuration must include the advertised route. LAN and Cloudflare Tunnel routes are later slices.
  • Revocation closes the device's open Remote streams and refuses further requests with a coded error distinct from a transport failure.
  • Client surface: "Paired devices" section in the existing Host/settings area of the Web Client with Pair, the QR/link, the device list and Revoke. Uses existing UI primitives (dsh-ui skill).
  • Diagnostics: structured, bounded developer log entries for offer created/redeemed/expired, device admitted/refused/revoked, never containing secrets (AGENTS.md developer diagnostics).

Testing Decisions

  • Test external behavior at the highest seam: the Device Pairing module's public interface (create offer → redeem → authenticate → revoke) with an in-memory/temporary operational database, the same way existing Host owner modules are tested in packages/core/test/.
  • One live isolated-Host test (as the live CLI E2E probes do, ADR-0159) proving: pair, restart the Host, the same device credential still calls a bridge method, revoke, and the next call is refused with the coded error.
  • No test asserts on internal storage layout or hashing details.

Out of Scope

Further Notes

Reference: t3code docs/user/remote-access.md (pairing links, routes, revocation via Settings → Connections), docs/internals/t3-connect.md, docs/internals/environment-auth.md. Existing seams: live CLI host connection (connectLiveHost), ADR-0159, ADR-0181, phone QA tunnel runbook.

Activity

  1. added this to the v2.0 milestone on Oct 14, 2026
  2. added
    ready-for-agentFully specified, ready for an AFK agent
    area:backendHost-side implementation
    scope:specNormative specification for follow-on slices
    feature:identityPersonaBot identity, lifecycle, and deletion
    on Oct 14, 2026
  3. DoodleBears commented on Oct 17, 2026

    @DoodleBears
    ContributorAuthor

    Human-authorized issue reconciliation (2026-10-18). Device pairing/remote-access specification has been implemented in main (#1658 / #1668), and its #1652 implementation slice is reconciled. Closing this delivered specification per Human instruction.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:backendHost-side implementationfeature:identityPersonaBot identity, lifecycle, and deletionready-for-agentFully specified, ready for an AFK agentscope:specNormative specification for follow-on slices

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions