feat: add companion API and Android APK shell

This commit is contained in:
Hermes Agent
2026-07-09 04:43:00 +00:00
parent bd0cf34aa3
commit 7eb9648eb7
92 changed files with 7907 additions and 877 deletions
@@ -1,12 +1,47 @@
import { FormEvent, useState } from 'react';
import { useCompanion } from '../../api/CompanionContext.js';
import { CompanionClient, DEFAULT_COMPANION_URL } from '../../api/companionClient.js';
export function SettingsScreen() {
const { client, settings, updateSettings } = useCompanion();
const [baseUrl, setBaseUrl] = useState(settings.baseUrl);
const [accessKey, setAccessKey] = useState(settings.accessKey);
const [status, setStatus] = useState('Run companion setup, paste the access key, then test the connection.');
function save(event: FormEvent<HTMLFormElement>): void {
event.preventDefault();
updateSettings({ baseUrl: baseUrl || DEFAULT_COMPANION_URL, accessKey });
setStatus('Settings saved.');
}
async function testConnection(): Promise<void> {
updateSettings({ baseUrl: baseUrl || DEFAULT_COMPANION_URL, accessKey });
setStatus('Testing connection…');
try {
const testClient = new CompanionClient({ baseUrl: baseUrl || DEFAULT_COMPANION_URL, accessKey });
await testClient.health();
const response = await testClient.validate();
setStatus(response.message);
} catch (caughtError) {
setStatus(caughtError instanceof Error ? caughtError.message : 'Connection failed');
}
}
return (
<section className="screen stack-screen">
<h2>Settings</h2>
<article className="settings-card">
<form className="settings-card" onSubmit={save}>
<label htmlFor="server-url">Companion server URL</label>
<input id="server-url" placeholder="https://hermes.local:8787" type="url" />
<p>Pairing, health checks, notification setup, and theme controls will expand from here.</p>
</article>
<input id="server-url" onChange={(event) => setBaseUrl(event.target.value)} placeholder={DEFAULT_COMPANION_URL} type="url" value={baseUrl} />
<label htmlFor="access-key">Access key</label>
<input id="access-key" onChange={(event) => setAccessKey(event.target.value)} placeholder="hm_…" type="password" value={accessKey} />
<div className="composer__actions">
<button className="small-button" type="submit">Save</button>
<button className="send-button" onClick={() => void testConnection()} type="button">Test connection</button>
</div>
<p>{status}</p>
</form>
</section>
);
}