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
+33 -9
View File
@@ -16,6 +16,8 @@ export interface FakeRun {
body: string;
sessionId: string;
input: string;
/** The profile the run was submitted under (null = default). Invisible from any other. */
profile: string | null;
status: string;
output: string;
extra: Record<string, unknown>;
@@ -40,7 +42,12 @@ export class FakeHermes {
private readonly byKey = new Map<string, FakeRun>();
/** session id -> inputs seen, to prove follow-ups land in the same session. */
readonly sessions = new Map<string, string[]>();
readonly requests: Array<{ method: string; path: string; idempotencyKey?: string }> = [];
readonly requests: Array<{ method: string; path: string; idempotencyKey?: string; profile?: string | null }> = [];
/** Named profiles served under `/p/<name>`, each with its own key. */
readonly profiles = new Map<string, string>();
/** Which profile each executed run belonged to (null = default), in order. */
readonly executedBy: Array<string | null> = [];
private script: Script[] = [];
private defaultScript: Script = { kind: 'complete' };
/** Faults applied to upcoming POST /v1/runs calls, in order. */
@@ -108,12 +115,24 @@ export class FakeHermes {
private async handle(req: IncomingMessage, res: ServerResponse): Promise<void> {
const url = new URL(req.url ?? '/', 'http://x');
const path = url.pathname;
let path = url.pathname;
// Like a gateway with multiplex_profiles: `/p/<profile>/...` selects a named profile, which
// has its OWN key; the default's key is refused there, and an unserved profile is a 404.
let profile: string | null = null;
let expectedKey = this.apiKey;
const prefixed = /^\/p\/([^/]+)(\/.*)$/.exec(path);
if (prefixed) {
profile = prefixed[1]!;
path = prefixed[2]!;
const profileKey = this.profiles.get(profile);
if (profileKey === undefined) return this.json(res, 404, { error: { message: 'Unknown profile' } });
expectedKey = profileKey;
}
const key = req.headers['idempotency-key'];
this.requests.push({ method: req.method ?? '', path, idempotencyKey: typeof key === 'string' ? key : undefined });
this.requests.push({ method: req.method ?? '', path, idempotencyKey: typeof key === 'string' ? key : undefined, profile });
if (path === '/health') return this.json(res, 200, { status: 'ok' });
if (req.headers.authorization !== `Bearer ${this.apiKey}`) {
if (req.headers.authorization !== `Bearer ${expectedKey}`) {
return this.json(res, 401, { error: { message: 'Invalid API key', code: 'invalid_api_key' } });
}
@@ -121,11 +140,12 @@ export class FakeHermes {
for await (const chunk of req) chunks.push(chunk as Buffer);
const raw = Buffer.concat(chunks).toString('utf8');
if (req.method === 'POST' && path === '/v1/runs') return this.submit(req, res, raw);
if (req.method === 'POST' && path === '/v1/runs') return this.submit(req, res, raw, profile);
const match = /^\/v1\/runs\/([^/]+)(\/stop)?$/.exec(path);
if (match) {
const run = this.runs.get(decodeURIComponent(match[1]!));
const found = this.runs.get(decodeURIComponent(match[1]!));
const run = found && found.profile === profile ? found : undefined;
if (req.method === 'GET' && !match[2]) {
if (this.statusDown) return this.json(res, 503, { error: { message: 'storage_unavailable' } });
if (!run) return this.json(res, 404, { error: { message: 'Run not found', code: 'run_not_found' } });
@@ -158,8 +178,10 @@ export class FakeHermes {
this.json(res, 404, { error: { message: 'not found' } });
}
private submit(req: IncomingMessage, res: ServerResponse, raw: string): void {
private submit(req: IncomingMessage, res: ServerResponse, raw: string, runProfile: string | null): void {
// Keys are scoped to the profile, as in Hermes: the same key under another profile is a different run.
const key = String(req.headers['idempotency-key'] ?? '');
const scopedKey = key && `${runProfile ?? ''}|${key}`;
const fault = this.submitFaults.shift();
if (fault === 'http_503') return this.json(res, 503, { error: { message: 'runtime_draining' } }, { 'Retry-After': '1' });
if (fault === 'http_400') return this.json(res, 400, { error: { message: "Missing 'input' field" } });
@@ -172,7 +194,7 @@ export class FakeHermes {
}
if (!body.input) return this.json(res, 400, { error: { message: "Missing 'input' field" } });
const existing = key ? this.byKey.get(key) : undefined;
const existing = scopedKey ? this.byKey.get(scopedKey) : undefined;
let run: FakeRun;
let replayed = false;
if (existing) {
@@ -191,6 +213,7 @@ export class FakeHermes {
body: raw,
sessionId,
input: body.input,
profile: runProfile,
status: 'running',
output: '',
extra: {},
@@ -198,9 +221,10 @@ export class FakeHermes {
timer: null,
};
this.runs.set(run.runId, run);
if (key) this.byKey.set(key, run);
if (scopedKey) this.byKey.set(scopedKey, run);
// The turn "executes" exactly once, at admission.
this.executions += 1;
this.executedBy.push(runProfile);
const history = this.sessions.get(sessionId) ?? [];
this.sessions.set(sessionId, history);
const script = this.script.shift() ?? this.defaultScript;