feat(tap): TapClient WSS pump loop (spec §4.2)

- run_tap_client: drives a connected WebSocketStream with a tokio::select!
  over rx_pcm_in (inbound PCM → audio_in WS frame) and ws.next() (brain
  frame → audio_out mpsc or control handling).
- Handshake: send hello, await brain hello (bounded 2s timeout).
- seq gap detection (log + count, never drop on gap — spec §3.1).
- Hot-path errors (encode/decode failures, send/recv failures) are logged
  + counted; TapClientError is returned only on graceful close, hello
  timeout, or WS errors. The TapEngine (Task 7) decides reconnect policy.
- Pure-helper unit test (elapsed_ms); full pump behavior is exercised
  against the in-process EchoServer in the Task 8 integration test.

Spec ref: 2026-06-28-slice-2-agent-tap-design.md §4.2.
This commit is contained in:
opencode controller
2026-06-28 14:25:15 -04:00
parent 51d5e6b01e
commit 1bb5b7203c
4 changed files with 269 additions and 0 deletions

1
Cargo.lock generated
View File

@@ -1209,6 +1209,7 @@ version = "0.1.0"
dependencies = [
"base64",
"futures-util",
"rutster-call-model",
"rutster-media",
"serde",
"serde_json",