feat(host): add the agent-device host front-end

Closed
VK
2mo ago
+986-5

Summary

Adds agent-device host, the Host front-end from ADR 0021 §3. It runs as its own process, starts or reuses the local HTTP daemon, and serves it to remote verification workers through @agent-device/proxy. The proxy command is untouched.

agent-device host --host 0.0.0.0 --port 8443 --tls-cert ./cert.pem --tls-key ./key.pem

Workers authenticate with one service credential at <state dir>/host/service-credential.json (directory 0700, file 0600). Host writes it once it is serving, prints the token that one time, and reuses it after restarts.

Host refuses to start, with a typed reason and before any daemon starts, when:

  • the credential is malformed, a link, or open to group or others;
  • a TLS file is unreadable, or the certificate and key don't load as a pair;
  • it would serve plain HTTP off loopback.

A wildcard bind advertises the machine's hostname; startup prints the exact worker command.

Closes #3265. 22 files, 991 gross lines, with chore(gates) last.

Validation

Tested commit 025fb41b9:

  • pnpm check:affected --run: all pass except a flaky affected-selector test (ENOTEMPTY on temp cleanup; unchanged from main). The 17 checks after it pass when run separately.
  • Tests cover:
    • hostCommand end to end against a stub daemon: public health, 401 for a wrong token, and an authenticated request reaching the daemon with the daemon token, across a restart that prints the token only once;
    • 404 on unserved routes;
    • each startup refusal, before any daemon starts;
    • an HTTPS round-trip.

No device-facing change.