Skip to content

latent.serve.tunnel

cloudflared quick-tunnel for latent serve --share (ADR-006 D2, T12a).

Spawns cloudflared tunnel --url http://127.0.0.1:<port> and parses the https://*.trycloudflare.com URL it prints, so a dev's local agent gets a public HTTPS URL to advertise to Studio. The tunnel process is owned by the returned :class:Tunnel; close() tears it down on shutdown.

Classes

Tunnel

Tunnel(process: subprocess.Popen, url: str)

A running cloudflared tunnel: its public url and the owning process.

Functions

open_tunnel

open_tunnel(port: int, timeout_s: float = 30.0) -> Tunnel

Start a cloudflared quick-tunnel to port and return it once the URL appears.

Raises RuntimeError if cloudflared is missing or never announces a URL.

parse_tunnel_url

parse_tunnel_url(line: str) -> str | None

Return the trycloudflare URL in line, or None if absent.

require_cloudflared

require_cloudflared(which: Callable[[str], str | None] = shutil.which) -> str

Return the cloudflared path, or raise with an install hint if absent.

which is the injectable lookup seam (defaults to shutil.which).

Methods

Tunnel.close

close() -> None