The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: keep native protocol fixtures within their runtime type boundary
Tekniumda98497cdc4b
diff --git a/apps/desktop/docs/canonical-gateway-protocol.md b/apps/desktop/docs/canonical-gateway-protocol.mdnew file mode 100644index 00000000000..4c76e931928--- /dev/null+++ b/apps/desktop/docs/canonical-gateway-protocol.md@@ -0,0 +1,55 @@+# Canonical local gateway protocol++Native local connections use the ordinary gateway owner. Closing Desktop,+changing profile or evicting a viewer never transfers that owner into Electron's+child-process pool. Local ensure retains the update gate and rechecks profile+retirement after asynchronous waits. Remote SSH, URL and OAuth routing retain+their existing authentication paths; failure never creates a local replacement.++## Authentication++`gateway ensure --json` returns a credential-free endpoint. Native main requests+private `session-ticket` grants with exactly `profile_id`, `instance_id` and+`purpose`. WebSocket grants use `interactive`; JSON HTTP requests use+`native-http`. Each HTTP retry mints a fresh grant and sends it only in+`X-Hermes-Gateway-Ticket`, scoped to the endpoint's exact origin. HTTP credentials+are not stored in the renderer or attached to URLs/public connection descriptors.++## Session and input identities++`src/api/canonical-protocol.ts` adapts only native canonical sockets. Creation+uses source `gui`, not `cli`. The foreground draft retains its `request_id` after+an uncertain create ACK; New chat starts a new intent. Unsupported explicit+launch settings are rejected visibly rather than silently dropped. Renderer+routing profile, terminal column count and disabled fast mode are not execution+policy overrides. This does not provide a crash-durable create-intent journal.++The canonical `admission_id` is distinct from the submitted input ID. Receipt+projection retains both and verifies `ref.session_id` against the requested+session before acknowledging the prepared input. The existing native private+atomic-file journal is still written before transport admission and retired only+after a matching accepted receipt. An unknown receipt retains it for explicit+retry. Renderer-only localStorage recovery is not native crash durability.++## Controls and metadata++Live and replayed prompt projections retain `prompt_id` and execution generation,+including named event listeners. Stop uses the captured session generation;+approval and clarify responses resolve the exact projected prompt, never the+latest arbitrary prompt. Resume restores pending approval/clarify projections.++Canonical `session.title` and `session.archive` RPC requests become+`session.mutate` with a retained request ID and expected revision. An ambiguous+failure retains that CAS payload; an explicit revision conflict requires a fresh+snapshot before retry. Existing REST metadata writers are not migrated by this+RPC adapter and do not yet provide universal revision fencing.++## Cutover limits++The canonical authority currently exposes a narrower RPC set than the full+Desktop application. Unsupported model/tool/slash/session-management RPCs,+cross-window pending-input text projection, non-JSON download authentication,+Windows validated named-pipe bootstrap, and WSL topology require further+integration. Successful authenticated transport is not proof of a usable mounted+chat or native journal retirement. End-to-end acceptance must compose the HTTP+grant server and drive real Electron controls with disposable userData.diff --git a/apps/desktop/src/api/canonical-protocol-wire.test.ts b/apps/desktop/src/api/canonical-protocol-wire.test.tsindex 8f0c3539acd..5632048afb9 100644--- a/apps/desktop/src/api/canonical-protocol-wire.test.ts+++ b/apps/desktop/src/api/canonical-protocol-wire.test.ts@@ -1,15 +1,16 @@// @vitest-environment nodeimport { expect, test } from 'vitest'-import { WebSocketServer } from 'ws'import { HermesGateway } from './client'test('named canonical prompt listeners receive replay-safe IDs before answering on the wire', async () => {+ 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 sent: any[] = []- server.on('connection', socket => {- socket.on('message', bytes => {+ server.on('connection', (socket: any) => {+ socket.on('message', (bytes: Buffer) => {const frame = JSON.parse(bytes.toString())sent.push(frame)socket.send(JSON.stringify({ jsonrpc: '2.0', id: frame.id, result: { status: 'resolved' } }))diff --git a/apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsx b/apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsxindex 2ded316faef..d51eb3b1375 100644--- a/apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsx+++ b/apps/desktop/src/app/session/hooks/use-prompt-actions/index.test.tsx@@ -296,7 +296,10 @@ describe('durable submit acknowledgement', () => {const os = await import('node:os')const path = await import('node:path')vi.doMock('electron', () => ({ app: {}, ipcMain: {} }))- const { preparedJournal } = await import('../../../../../electron/prepared-submissions')+ // Exercise the native module at runtime without importing its separate,+ // non-strict Electron project into the renderer's TypeScript project.+ const nativeJournalModule = '../../../../../electron/prepared-submissions'+ const { preparedJournal } = await import(nativeJournalModule)const home = fs.mkdtempSync(path.join(os.tmpdir(), 'desktop-retire-'))const journal = preparedJournal(home, 'http://native-fixture')const previous = window.hermesDesktop