|
| 1 | +# macOS Desktop-App Guide |
| 2 | + |
| 3 | +KeyClaw's CLI wrappers are the preferred macOS path because they inject proxy settings and CA trust into the child process directly. |
| 4 | + |
| 5 | +Finder-launched apps are different. `Claude.app`, `Codex.app`, `ChatGPT.app`, and similar GUI clients are launched by macOS, not by your shell, so they do not reliably inherit the proxy environment you get from `source ~/.keyclaw/env.sh`. |
| 6 | + |
| 7 | +The current supported path for macOS desktop apps is: |
| 8 | + |
| 9 | +1. initialize KeyClaw normally |
| 10 | +2. trust `~/.keyclaw/ca.crt` in the login keychain for SSL |
| 11 | +3. run a healthy KeyClaw proxy |
| 12 | +4. enable the macOS HTTP and HTTPS system proxy on the active network service |
| 13 | +5. fully relaunch the desktop app |
| 14 | + |
| 15 | +## Prerequisites |
| 16 | + |
| 17 | +Run the normal first-run setup first: |
| 18 | + |
| 19 | +```bash |
| 20 | +keyclaw init |
| 21 | +keyclaw proxy |
| 22 | +keyclaw proxy status |
| 23 | +``` |
| 24 | + |
| 25 | +If `keyclaw proxy status` is not healthy, do not enable the macOS system proxy yet. A system proxy that points at a dead KeyClaw listener can break browser and desktop-app connectivity. |
| 26 | + |
| 27 | +## Trust The KeyClaw CA |
| 28 | + |
| 29 | +Trust `~/.keyclaw/ca.crt` in the login keychain for SSL: |
| 30 | + |
| 31 | +```bash |
| 32 | +security add-trusted-cert -r trustRoot -p ssl -k ~/Library/Keychains/login.keychain-db ~/.keyclaw/ca.crt |
| 33 | +killall trustd || true |
| 34 | +``` |
| 35 | + |
| 36 | +Verify it: |
| 37 | + |
| 38 | +```bash |
| 39 | +security verify-cert -c ~/.keyclaw/ca.crt -k ~/Library/Keychains/login.keychain-db -p ssl |
| 40 | +``` |
| 41 | + |
| 42 | +Use the user login keychain path above. The desktop-app trace showed that an incorrect trust-domain shape can still leave Electron/Chromium apps rejecting the KeyClaw CA with certificate-authority errors. |
| 43 | + |
| 44 | +## Enable The System Proxy |
| 45 | + |
| 46 | +Find the active network service if needed: |
| 47 | + |
| 48 | +```bash |
| 49 | +route get default |
| 50 | +networksetup -listnetworkserviceorder |
| 51 | +``` |
| 52 | + |
| 53 | +Then enable the proxy on that service. Example for `Wi-Fi`: |
| 54 | + |
| 55 | +```bash |
| 56 | +networksetup -setwebproxy "Wi-Fi" 127.0.0.1 8877 off |
| 57 | +networksetup -setsecurewebproxy "Wi-Fi" 127.0.0.1 8877 off |
| 58 | +networksetup -setwebproxystate "Wi-Fi" on |
| 59 | +networksetup -setsecurewebproxystate "Wi-Fi" on |
| 60 | +networksetup -setproxybypassdomains "Wi-Fi" localhost 127.0.0.1 "*.local" "169.254/16" |
| 61 | +``` |
| 62 | + |
| 63 | +Check the live state: |
| 64 | + |
| 65 | +```bash |
| 66 | +networksetup -getwebproxy "Wi-Fi" |
| 67 | +networksetup -getsecurewebproxy "Wi-Fi" |
| 68 | +scutil --proxy |
| 69 | +``` |
| 70 | + |
| 71 | +You want both HTTP and HTTPS proxies enabled and pointing at `127.0.0.1:8877`. |
| 72 | + |
| 73 | +## Relaunch And Verify |
| 74 | + |
| 75 | +Fully quit and relaunch the desktop app after changing the proxy: |
| 76 | + |
| 77 | +```bash |
| 78 | +osascript -e 'tell application "Claude" to quit' || true |
| 79 | +open -a Claude |
| 80 | +``` |
| 81 | + |
| 82 | +Use the same pattern for `Codex` or `ChatGPT`. |
| 83 | + |
| 84 | +Useful verification checks: |
| 85 | + |
| 86 | +```bash |
| 87 | +keyclaw proxy status |
| 88 | +lsof -nP -iTCP:8877 |
| 89 | +tail -n 50 ~/.keyclaw/audit.log |
| 90 | +``` |
| 91 | + |
| 92 | +Healthy signs: |
| 93 | + |
| 94 | +- the app or its network helper has a live `127.0.0.1:* -> 127.0.0.1:8877` connection |
| 95 | +- `keyclaw proxy status` reports the proxy as healthy |
| 96 | +- audit-log entries or runtime logs show real provider hosts instead of only `stdin` or localhost test traffic |
| 97 | + |
| 98 | +## Roll Back |
| 99 | + |
| 100 | +To stop forcing macOS desktop traffic through KeyClaw: |
| 101 | + |
| 102 | +```bash |
| 103 | +networksetup -setwebproxystate "Wi-Fi" off |
| 104 | +networksetup -setsecurewebproxystate "Wi-Fi" off |
| 105 | +``` |
| 106 | + |
| 107 | +Then relaunch the desktop app again. |
| 108 | + |
| 109 | +## Notes |
| 110 | + |
| 111 | +- The CLI wrappers remain the simpler and higher-confidence path when they are available. |
| 112 | +- Desktop-app support depends on both correct CA trust and a healthy system-proxy listener. |
| 113 | +- If traffic still \"feels low,\" inspect `keyclaw proxy stats`, `~/.keyclaw/audit.log`, and runtime logs before assuming detection is broken. |
0 commit comments