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
+16 -2
View File
@@ -4,6 +4,7 @@ import {
AUDIO_FORMAT,
AudioTurnQuery,
check,
AgentsResponse,
ConversationCreateRequest,
httpStatusFor,
isRetryable,
@@ -17,7 +18,7 @@ import {
type ErrorResponse,
type Limits,
} from '@hermeven/contracts';
import type { BridgeConfig } from './config.ts';
import { DEFAULT_AGENT_ID, type BridgeConfig } from './config.ts';
import type { DeviceRow, Devices } from './devices.ts';
import type { HermesAdapter } from './hermes/adapter.ts';
import { RateLimiter } from './ratelimit.ts';
@@ -218,6 +219,16 @@ export async function buildServer(deps: ServerDeps): Promise<FastifyInstance> {
};
});
/**
* The agents this device may talk to, default first. Names only: no address, profile or key
* ever leaves the bridge. A separate route (not a field on /v1/device) so that clients built
* before it existed, which reject unknown fields, keep working.
*/
app.get('/v1/agents', async (req): Promise<AgentsResponse> => {
authenticate(req);
return { schema_version: SCHEMA_VERSION, agents: config.agents.map(({ id, name }) => ({ id, name })) };
});
app.post('/v1/device/renew', async (req) => {
const device = authenticate(req);
const renewed = devices.renew(device.id);
@@ -238,7 +249,10 @@ export async function buildServer(deps: ServerDeps): Promise<FastifyInstance> {
const body = req.body as Record<string, unknown> | undefined;
requireVersion(body?.schema_version);
if (!check(ConversationCreateRequest, body)) throw new ApiError('invalid_request', 'Malformed conversation request.');
const conversation = engine.createConversation(device.id);
const agentId = (body as { agent_id?: string }).agent_id ?? DEFAULT_AGENT_ID;
// Only an agent the owner listed. The id is never used to build an address here.
if (!engine.knowsAgent(agentId)) throw new ApiError('invalid_request', 'Unknown agent.');
const conversation = engine.createConversation(device.id, agentId);
reply.code(201);
return { schema_version: SCHEMA_VERSION, conversation_id: conversation.id, created_at: iso(conversation.created_at) };
});