th-e82dac: implement th tunnel client (SMOODEV-401)#149
Merged
Conversation
…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
🦋 Changeset detectedLatest commit: af7fc1c The changes in this PR will be included in the next version bump. This PR includes changesets to release 1 package
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 startnow actually dials out and proxies, replacing theNotImplementedYetscaffold.TunnelClient::run:wss://th.smoo.ai/tunnel, sendsClientHello, awaitsServerHello, surfaces the assigned<slug>.th.smoo.aipublic URL via anon_readycallback (CLI prints it green the moment it's live).StreamOpen→ assemble the request fromStreamDatabinary frames → replay against the local Big Smooth → stream the response back asStreamData+StreamClose.Bye/Control/close handling.StreamClose(follow-up).smooai-fetch over reqwest
Per direction, the local-target proxy uses the house
smooai-fetchclient (git dep, rev-pinned likesmooai-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)
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.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