2.5 KiB
2.5 KiB
Companion Server
The companion server is a local Fastify HTTP API that the Android app talks to. It runs beside Hermes Agent and keeps Hermes core untouched.
Setup
Install dependencies, generate an access key, and start the server:
npm install
npm run companion:setup
npm run companion:dev
npm run companion:setup runs the local hermes-mobile-companion setup command. It creates ~/.config/hermes-mobile/companion.json, prints the generated hm_... access key, and stores the safe workspace root.
Useful environment variables:
PORTdefaults to8787.HOSTdefaults to0.0.0.0so Android emulators/devices can connect.HERMES_MOBILE_CONFIGoverrides the config JSON path.HERMES_MOBILE_ACCESS_KEYoverrides the stored key.HERMES_MOBILE_WORKSPACE_ROOTsets the file/terminal allowlisted root.
Pairing
- Run
npm run companion:setupon the computer running Hermes. - Copy the printed access key.
- Open Hermes Mobile Settings.
- Use
http://10.0.2.2:8787for the Android emulator, orhttp://<LAN-IP>:8787for a physical phone on the same network. - Paste the access key and tap Test connection.
All non-health API requests require:
Authorization: Bearer <access-key>
API
GET /api/healthreturns service, Hermes CLI, auth, uptime, and workspace status.GET /api/auth/validatevalidates the bearer token.POST /api/chataccepts{ "prompt": "..." }and invokes the localhermesCLI when it is onPATH.GET /api/files?path=.lists files under the configured workspace root.GET /api/files/read?path=README.mdreads UTF-8 file content.POST /api/files/writewrites{ "path": "notes.txt", "content": "..." }under the workspace root.GET /api/files/metadata?path=README.mdreturns file metadata for download-style clients.POST /api/terminal/runruns{ "command": "pwd && ls", "cwd": ".", "timeoutMs": 10000 }under the workspace root.
Security Model
This is a private LAN/local companion, not an internet-facing service. Security controls are intentionally simple but strict for the MVP:
- Bearer token required for every non-health endpoint.
- File and terminal
cwdaccess is constrained toHERMES_MOBILE_WORKSPACE_ROOTor the stored setup root. - The mobile file explorer hides
.git,.dev,node_modules,dist, and generated Android build folders. - Path traversal outside the root is rejected.
- Terminal commands run with a configurable timeout capped at 30 seconds.
- Secrets live in local config or environment variables, never in the repo.