Store API keys in the Keychain instead of settings.json
Follow-up from the #63 review.
API keys and tokens are saved in plain text in Documents/settings.json, together with the other settings. There are 8 of them:
openClawAuthTokengeminiAPIKeyopenAIAPIKeygrokAPIKeyhermesAPIKeytavilyAPIKeytelemetryTokentelemetryPassword
The subscription sign-ins (ChatGPT, SuperGrok, Hermes web UI) already keep their tokens in the Keychain. The Hermes API key matters most, because it gives access to a terminal on the user's server, but the same reasoning applies to every key.
Proposal:
- Keep the fields in
AppSettingsin memory, so views and services don't change.SettingsManagersaves them to the Keychain (after first unlock, this device only, like the OAuth tokens) and writes them blank tosettings.json. - Migration: when
settings.jsonfrom an older build still has a key, it is moved to the Keychain on launch, and the file is rewritten without it. - Never lose a key:
- If the Keychain can't be read (for example, a launch before the phone's first unlock), the key is never overwritten or deleted.
- If a Keychain write fails, the key stays in the file.
Live check: Hermes API-key mode
Also from the #63 review: the response shape of /v1/capabilities, which "Test Connection" reads in API-key mode, hasn't been checked against a live server yet. I'll post the result here.
Live check result: on the user's own Hermes server, with the API server enabled, Test Connection in API-key mode succeeded ("Connected"). /v1/capabilities returns the shape HermesService.parseCapabilities expects, so no change is needed there.
A UX gap showed up during setup: an address typed without https:// or http:// (e.g. myhost.ts.net) is rejected with "Enter the server address, e.g. https://hermes.example.com." That's correct, but easy to trip on. I can open a small PR that adds the scheme automatically:
https://for host nameshttp://for loopback, LAN and Tailscale IPs
This would apply to both Hermes address fields.