The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): build a sibling profile's ticket home from the resolved root
Teknium46a4d5d4a5f8
diff --git a/apps/desktop/electron/local-gateway-symlinked-home.test.ts b/apps/desktop/electron/local-gateway-symlinked-home.test.tsnew file mode 100644index 00000000000..15fa5df44b3--- /dev/null+++ b/apps/desktop/electron/local-gateway-symlinked-home.test.ts@@ -0,0 +1,25 @@+import fs from 'node:fs'+import os from 'node:os'+import path from 'node:path'++import { expect, test } from 'vitest'++import { routedGatewayEndpoint } from './local-gateway'++// B2-17: with a symlinked ~/.hermes (dotfiles link, macOS /var -> /private/var) the raw launch+// HERMES_HOME is not canonical. The sibling profile home is built from the endpoint's own resolved+// profile_id, so mintLocalGatewayTicket's realpath check holds instead of 'Noncanonical gateway profile'.+test.skipIf(process.platform === 'win32')('a sibling route under a symlinked launch home is canonical', () => {+ const base = fs.realpathSync(fs.mkdtempSync(path.join(os.tmpdir(), 'desktop-symlink-home-')))+ const real = path.join(base, 'real')+ fs.mkdirSync(path.join(real, 'profiles', 'work'), { recursive: true })+ fs.symlinkSync(real, path.join(base, 'link'))+ const endpoint = { profile_id: real, instance_id: 'i', authority_epoch: 1, runtime_protocol: 1, api_origin: 'http://127.0.0.1:1', capabilities: [], supervisor: 'none' as const, control_home: null }++ try {+ const routed = routedGatewayEndpoint(endpoint as never, 'work', path.join(base, 'link'))+ expect(routed.profile_id).toBe(path.join(real, 'profiles', 'work'))+ expect(fs.realpathSync(routed.profile_id)).toBe(routed.profile_id)+ expect(routedGatewayEndpoint(endpoint as never, 'default', path.join(base, 'link'))).toBe(endpoint)+ } finally { fs.rmSync(base, { recursive: true, force: true }) }+})diff --git a/apps/desktop/electron/local-gateway.ts b/apps/desktop/electron/local-gateway.tsindex 66d68b68382..1f5b19fc59a 100644--- a/apps/desktop/electron/local-gateway.ts+++ b/apps/desktop/electron/local-gateway.ts@@ -315,7 +315,7 @@ function shellQuote(file: string): string {/** The endpoint a `?profile=<name>` request is scoped to on a shared host descriptor: the same* daemon, ticket minted for the sibling profile's home (`profiles/<name>` under the launch root).* The gateway refuses a ticket whose profile it does not serve, so a bad name fails closed. */-export function routedGatewayEndpoint(endpoint: GatewayEndpoint, urlOrProfile: string, launchHome: string): GatewayEndpoint {+export function routedGatewayEndpoint(endpoint: GatewayEndpoint, urlOrProfile: string, _launchHome: string): GatewayEndpoint {const profile = (/^[a-z]+:\/\//.test(urlOrProfile) ? new URL(urlOrProfile).searchParams.get('profile') : urlOrProfile)?.trim()if (!profile || profile === 'current') {return endpoint}@@ -325,7 +325,9 @@ export function routedGatewayEndpoint(endpoint: GatewayEndpoint, urlOrProfile: sif (profile === ownName) {return endpoint}if (!/^[A-Za-z0-9][A-Za-z0-9._-]*$/.test(profile)) {throw new Error('Invalid profile route')}- const root = path.basename(path.dirname(endpoint.profile_id)) === 'profiles' ? path.dirname(path.dirname(endpoint.profile_id)) : launchHome+ // The root home is the endpoint's own profile_id (Python resolved it); the raw launch HERMES_HOME+ // may be a symlink, and a ticket for an unresolved sibling home fails 'Noncanonical' (B2-17).+ const root = path.basename(path.dirname(endpoint.profile_id)) === 'profiles' ? path.dirname(path.dirname(endpoint.profile_id)) : endpoint.profile_idconst home = profile === 'default' ? root : path.join(root, 'profiles', profile)return { ...endpoint, profile_id: home, control_home: endpoint.control_home || endpoint.profile_id }