Skip to content

th-e82dac: implement th tunnel client (SMOODEV-401)#149

Merged
brentrager merged 3 commits into
mainfrom
th-e82dac-tunnel-impl
Jul 3, 2026
Merged

th-e82dac: implement th tunnel client (SMOODEV-401)#149
brentrager merged 3 commits into
mainfrom
th-e82dac-tunnel-impl

Conversation

@brentrager

Copy link
Copy Markdown
Contributor

What

Implements the client leg of th.smoo.ai — the feature on the marketing page: "Lives on your machine — reachable from your phone." th tunnel start now actually dials out and proxies, replacing the NotImplementedYet scaffold.

TunnelClient::run:

  • Dials wss://th.smoo.ai/tunnel, sends ClientHello, awaits ServerHello, surfaces the assigned <slug>.th.smoo.ai public URL via an on_ready callback (CLI prints it green the moment it's live).
  • Multiplexes inbound HTTP: StreamOpen → assemble the request from StreamData binary frames → replay against the local Big Smooth → stream the response back as StreamData + StreamClose.
  • Ping→Pong keepalive; clean Bye/Control/close handling.
  • Inbound WebSocket streams are rejected with a StreamClose (follow-up).

smooai-fetch over reqwest

Per direction, the local-target proxy uses the house smooai-fetch client (git dep, rev-pinned like smooai-client-shared) rather than raw reqwest — retries OFF (a proxy must never silently re-send a visitor's non-idempotent request), per-request timeout + circuit breaker on.

Known ceilings (follow-ups, tracked on th-e82dac)

  • Binary response fidelity: smooai-fetch carries the body as String, so responses are UTF-8-faithful (JSON/HTML — the review-from-phone path) but lossy for binary web-bundle assets. Raw-bytes response path is the follow-up.
  • WebSocket-stream proxying (live chat socket over the tunnel).
  • smooai-fetch pulls reqwest's default native-tls; could align on the workspace's rustls in a later pass.

Tests

29 tunnel-crate tests incl. an in-process handshake + HTTP-proxy round-trip against a mock rendezvous + mock local target (proves dial → hello → StreamOpen → local request → response frames, and that the public-URL Host is stripped). Method/header/body mapping unit-tested. 277 CLI tests green, clippy clean.

Closes pearl th-e82dac. Server side stays in the smooai monorepo (SMOODEV-637 / th-8898f2).

🤖 Generated with Claude Code

https://claude.ai/code/session_01KTAAbdrbdQSy8dVK7nsH96

…plex

SMOODEV-401 client leg. TunnelClient::run now:
- dials wss://th.smoo.ai/tunnel, sends ClientHello, awaits ServerHello,
  surfaces the assigned public URL via an on_ready callback
- multiplexes inbound HTTP: StreamOpen → assemble request from
  StreamData binary frames → replay against local Big Smooth → stream
  the response back as StreamData + StreamClose
- answers Ping with Pong, handles Bye/Control/close cleanly
- rejects inbound WebSocket streams with a StreamClose (follow-up)

Local requests go through the house smooai-fetch client (git dep,
rev-pinned like client-shared) instead of raw reqwest — retries OFF
(a proxy must not re-send a visitor's POST), timeout + circuit breaker
on. Body is String-carried: UTF-8-faithful for the control-plane
traffic (JSON/HTML), lossy for binary — raw-bytes path is the follow-up.

NotImplementedYet is gone. 29 tunnel tests incl. an in-process
handshake + HTTP-proxy round-trip against a mock rendezvous + mock
local target; method/header/body mapping unit-tested. 277 CLI tests
green, clippy clean.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KTAAbdrbdQSy8dVK7nsH96
@brentrager brentrager enabled auto-merge (squash) July 3, 2026 05:08
@changeset-bot

changeset-bot Bot commented Jul 3, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: af7fc1c

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@smooai/smooth Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@brentrager brentrager merged commit 280d712 into main Jul 3, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant