# Cloudflared Quick Tunnel on ZimaOS

Temporary public exposure of a local service via Cloudflare's trycloudflare.com. No account needed, but no uptime guarantee — tunnels die after hours/days.

## Prerequisites

```bash
# Download cloudflared binary (one-time)
curl -L https://github.com/cloudflare/cloudflared/releases/latest/download/cloudflared-linux-amd64 -o /tmp/cloudflared
chmod +x /tmp/cloudflared
```

## Start Tunnel

```bash
# Start tunnel in background, pointing at local service
/tmp/cloudflared tunnel --url http://127.0.0.1:PORT 2>&1 &

# The URL appears in logs after ~5-10 seconds:
# |  https://<random-name>.trycloudflare.com  |
```

## Extract URL from Running Tunnel

```bash
# Poll the background process for the URL line
# The URL is on a line matching "https://...trycloudflare.com"
# Use process tool: poll until uptime > 10s, then log with limit=50
# grep for "trycloudflare.com" in output
```

## Full Workflow (Hermes Agent)

1. Ensure local service is running on 127.0.0.1:PORT
2. Start cloudflared with `terminal(background=true, timeout=30)`
3. Poll with `process(action='poll')` until uptime > 10 seconds
4. Get full log with `process(action='log', limit=50)`
5. Extract URL from the line containing `trycloudflare.com`
6. Report URL to user as `https://<name>.trycloudflare.com/PATH`

## Pitfalls

- **Tunnels die silently.** No notification. User will report "funktioniert nicht mehr" — just restart.
- **URL changes every restart.** Quick Tunnels get random subdomains. Cannot choose the name.
- **Old tunnel process may still hold the port.** Kill stale cloudflared processes before starting new one: `pkill -f "cloudflared tunnel"` (but be careful not to kill the new one).
- **For persistent URLs**, need a Cloudflare account + named tunnel + domain. Quick Tunnels are temporary only.
- **The `tput` noise** in logs is harmless — ZimaOS shell has no $TERM set.
