Choose an agent with a swipe at Ready (0.2.0)

Bridge: an owner-configured list of agents (HERMEVEN_AGENTS). Each extra
agent is another profile of the same Hermes gateway, reached at
/p/<profile> with that profile's own key. GET /v1/agents lists ids and
names; POST /v1/conversations takes an optional agent_id checked against
the list. A conversation belongs to one agent (migration v3) and its turns
are submitted, polled and stopped at that agent. /v1/device is unchanged so
clients built earlier keep working.

Client: at Ready a swipe moves between agents; the name is shown through
the exchange; each agent keeps its own conversation; a follow-up goes to
the agent that answered. Reopened within the conversation window it opens
on the last agent, otherwise on the default. With one agent, or a bridge
without /v1/agents, nothing changes.

Also: contract section G, server survey and key evidence, the 0.1.2
upload, and the CODY-020 correction. Not reviewed, not deployed, not
uploaded.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
Dan
2026-11-21 16:08:11 -08:00
co-authored by Claude Fable 5.2
parent 15714bd848
commit 9394c249ad
20 changed files with 1117 additions and 42 deletions
+62 -1
View File
@@ -3,6 +3,17 @@ import { fileURLToPath } from 'node:url';
import { AUDIO_FORMAT, DEFAULT_LIMITS } from '@hermeven/contracts';
import { validateManifest, type ModelManifest } from './stt/modelStore.mjs';
export interface AgentConfig {
/** `default` for the main agent; otherwise the id from HERMEVEN_AGENTS. */
id: string;
/** Shown on the glasses. */
name: string;
baseUrl: string;
apiKey: string;
}
export const DEFAULT_AGENT_ID = 'default';
export interface BridgeConfig {
host: string;
port: number;
@@ -30,6 +41,11 @@ export interface BridgeConfig {
pollIntervalMs: number;
requestTimeoutMs: number;
};
/**
* Every agent a paired device may talk to, default first. The list is the owner's allow-list:
* a client can only name an id from it. Each agent has its own Hermes address and its own key.
*/
agents: AgentConfig[];
stt: {
provider: 'none' | 'builtin' | 'openai-compatible';
baseUrl: string;
@@ -134,6 +150,49 @@ function loadModelManifest(name: string, customPath: string | undefined): ModelM
}
}
const AGENT_ID = /^[a-z][a-z0-9_-]{0,31}$/;
function agentName(key: string, raw: string | undefined, fallback: string): string {
const name = (raw ?? '').trim() || fallback;
if (name.length > 24 || /[\u0000-\u001f]/.test(name)) throw new ConfigError(`${key} must be at most 24 printable characters`);
return name;
}
/**
* The default agent is the Hermes API server at HERMES_BASE_URL with HERMES_API_KEY. Further
* agents are named in HERMEVEN_AGENTS (comma-separated ids) and are other profiles served by
* the same Hermes gateway under `/p/<profile>` (gateway.multiplex_profiles). Hermes gives each
* profile its own key and refuses the default's, so every extra agent needs
* HERMEVEN_AGENT_<ID>_API_KEY. Optional: HERMEVEN_AGENT_<ID>_PROFILE (default: the id) and
* HERMEVEN_AGENT_<ID>_NAME (default: the id, capitalised).
*/
function agentsFromEnv(env: NodeJS.ProcessEnv, baseUrl: string, defaultKey: string): AgentConfig[] {
const agents: AgentConfig[] = [
{ id: DEFAULT_AGENT_ID, name: agentName('HERMEVEN_AGENT_NAME', env.HERMEVEN_AGENT_NAME, 'Agent'), baseUrl, apiKey: defaultKey },
];
const ids = (env.HERMEVEN_AGENTS ?? '')
.split(',')
.map((s) => s.trim())
.filter(Boolean);
for (const id of ids) {
if (!AGENT_ID.test(id)) throw new ConfigError('HERMEVEN_AGENTS entries must be lower-case ids (letters, digits, - and _)');
if (agents.some((a) => a.id === id)) throw new ConfigError(`HERMEVEN_AGENTS names "${id}" more than once (or uses the reserved id "default")`);
const prefix = `HERMEVEN_AGENT_${id.toUpperCase().replace(/-/g, '_')}`;
const apiKey = env[`${prefix}_API_KEY`] || '';
if (!apiKey) throw new ConfigError(`${prefix}_API_KEY is required: Hermes gives each profile its own API key`);
const profile = env[`${prefix}_PROFILE`] || id;
if (!/^[A-Za-z0-9][A-Za-z0-9_-]{0,63}$/.test(profile)) throw new ConfigError(`${prefix}_PROFILE is not a valid profile name`);
agents.push({
id,
name: agentName(`${prefix}_NAME`, env[`${prefix}_NAME`], id.charAt(0).toUpperCase() + id.slice(1)),
baseUrl: `${baseUrl}/p/${profile}`,
apiKey,
});
}
if (agents.length > 16) throw new ConfigError('HERMEVEN_AGENTS lists too many agents (at most 15 besides the default)');
return agents;
}
export function loadConfig(env: NodeJS.ProcessEnv = process.env): BridgeConfig {
const host = env.HERMEVEN_HOST || '127.0.0.1';
const allowNonLoopback = bool(env, 'HERMEVEN_ALLOW_NON_LOOPBACK');
@@ -146,6 +205,7 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): BridgeConfig {
const hermesKey = env.HERMES_API_KEY || '';
if (!hermesKey) throw new ConfigError('HERMES_API_KEY is required (the Hermes API server refuses to start without one)');
const hermesBaseUrl = httpUrl('HERMES_BASE_URL', env.HERMES_BASE_URL || 'http://127.0.0.1:8642').replace(/\/+$/, '');
const originEntries = (env.HERMEVEN_ALLOWED_ORIGINS || '')
.split(',')
@@ -206,13 +266,14 @@ export function loadConfig(env: NodeJS.ProcessEnv = process.env): BridgeConfig {
allowNonLoopback,
trustProxy: bool(env, 'HERMEVEN_TRUST_PROXY'),
hermes: {
baseUrl: httpUrl('HERMES_BASE_URL', env.HERMES_BASE_URL || 'http://127.0.0.1:8642'),
baseUrl: hermesBaseUrl,
apiKey: hermesKey,
profileLabel: env.HERMES_PROFILE_LABEL || 'default',
instructions: env.HERMEVEN_INSTRUCTIONS === undefined ? DEFAULT_INSTRUCTIONS : env.HERMEVEN_INSTRUCTIONS,
pollIntervalMs: int(env, 'HERMES_POLL_INTERVAL_MS', 150, 20, 10_000),
requestTimeoutMs: int(env, 'HERMES_REQUEST_TIMEOUT_MS', 10_000, 50, 120_000),
},
agents: agentsFromEnv(env, hermesBaseUrl, hermesKey),
stt: {
provider: sttProvider,
baseUrl: sttBaseUrl,