The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): a legacy remote branches from a message without the canonical row boundary
Teknium59d6088606d6
diff --git a/apps/desktop/src/api/canonical-protocol-wire.test.ts b/apps/desktop/src/api/canonical-protocol-wire.test.tsindex c35b420d907..062fa5c6c8e 100644--- a/apps/desktop/src/api/canonical-protocol-wire.test.ts+++ b/apps/desktop/src/api/canonical-protocol-wire.test.ts@@ -71,6 +71,39 @@ test('a legacy (non-canonical) dial strips canonical-only identity keys the serv}})+test('a legacy dial branches from a message with the serve contract\'s count, never the canonical row boundary', async () => {+ // N20: the legacy `session.branch` contract is closed (extra="forbid"); `through_message_id`+ // answered 4000 "out of sync", which is not a missing method, so "Branch from here" failed.+ const wsPackage = 'ws'+ const { WebSocketServer } = await import(wsPackage)+ const server = new WebSocketServer({ host: '127.0.0.1', port: 0 })+ await new Promise<void>(resolve => server.once('listening', resolve))+ const allowed = new Set(['session_id', 'name', 'count', 'idempotency_key'])+ server.on('connection', (socket: any) => {+ socket.on('message', (bytes: Buffer) => {+ const frame = JSON.parse(bytes.toString())+ const unknown = Object.keys(frame.params).filter(key => !allowed.has(key))++ socket.send(JSON.stringify(unknown.length+ ? { jsonrpc: '2.0', id: frame.id, error: { code: 4000, message: `invalid params: ${unknown}` } }+ : { jsonrpc: '2.0', id: frame.id, result: { session_id: 'child', kept: frame.params.count } }))+ })+ })+ const client = new HermesGateway()++ try {+ const address = server.address() as { port: number }+ await client.connect(`ws://127.0.0.1:${address.port}/api/ws?ticket=legacy`)+ await expect(client.request('session.branch', { session_id: 'parent', idempotency_key: 'k', count: 3, through_message_id: 41 }))+ .resolves.toMatchObject({ session_id: 'child', kept: 3 })+ } finally {+ client.close()++ for (const socket of server.clients) { socket.terminate() }+ await new Promise<void>(resolve => server.close(() => resolve()))+ }+})+test('a compress settle resumes under the caller\'s original timeout and abort signal', async () => {// R4: the follow-up `session.resume` must not fall back to the default 120 s deadline// and ignore the caller's AbortSignal (a cancelled compress would otherwise hang).diff --git a/apps/desktop/src/api/client.ts b/apps/desktop/src/api/client.tsindex 774c6f626c6..13c79c35dfd 100644--- a/apps/desktop/src/api/client.ts+++ b/apps/desktop/src/api/client.ts@@ -51,8 +51,13 @@ const PARENT_ATTACH_REQUIRED = new Set(['session.branch_stored', 'session.branch// Canonical-only identity keys. The legacy `hermes serve` contract refuses an unknown key as// version skew (4000), so they are stripped on a non-canonical dial. `prompt.submit` keeps its// `submission_id` on purpose: the submit path retries identityless on that exact refusal and-// records the send as legacy-attempted, which a silent strip here would hide.-const LEGACY_STRIP: Record<string, string[]> = { 'session.create': ['request_id'], 'session.branch_stored': ['request_id'] }+// records the send as legacy-attempted, which a silent strip here would hide. A message-level+// `session.branch` keeps its legacy `count` prefix; only the canonical row boundary is dropped.+const LEGACY_STRIP: Record<string, string[]> = {+ 'session.create': ['request_id'],+ 'session.branch_stored': ['request_id'],+ 'session.branch': ['through_message_id']+}function legacyParams(method: string, params: Record<string, unknown>): Record<string, unknown> {const strip = LEGACY_STRIP[method]