The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): split ensureLocalGateway and startHermes failure CC
Tekniumfbc6be81faae
diff --git a/apps/desktop/electron/local-gateway.ts b/apps/desktop/electron/local-gateway.tsindex 0c7cefb0d9a..db698570f5c 100644--- a/apps/desktop/electron/local-gateway.ts+++ b/apps/desktop/electron/local-gateway.ts@@ -128,6 +128,18 @@ export function staleGatewayCode(payload: Record<string, any>): { gateway: strinreturn gateway.toLowerCase() === client.toLowerCase() ? null : { gateway, client }}+/** Loopback-only, bare-origin, session-authority endpoint or throw. */+function assertLocalGatewayEndpoint(endpoint: GatewayEndpoint): void {+ const origin = new URL(endpoint.api_origin)++ if (!['http:', 'https:'].includes(origin.protocol) || !['127.0.0.1', '[::1]'].includes(origin.hostname)+ || origin.username || origin.password || origin.pathname !== '/' || origin.search || origin.hash+ || !origin.port || endpoint.runtime_protocol !== 1 || !endpoint.instance_id || !endpoint.profile_id+ || !endpoint.capabilities.includes('session-authority-v1')) {+ throw new Error('Invalid local gateway endpoint')+ }+}+export async function ensureLocalGateway(run: () => Promise<{ code: number; stdout: string; stderr?: string }>,beforeEnsure?: () => Promise<void>,@@ -150,14 +162,7 @@ export async function ensureLocalGateway(}const endpoint: GatewayEndpoint = payload.endpoint- const origin = new URL(endpoint.api_origin)-- if (!['http:', 'https:'].includes(origin.protocol) || !['127.0.0.1', '[::1]'].includes(origin.hostname)- || origin.username || origin.password || origin.pathname !== '/' || origin.search || origin.hash- || !origin.port || endpoint.runtime_protocol !== 1 || !endpoint.instance_id || !endpoint.profile_id- || !endpoint.capabilities.includes('session-authority-v1')) {- throw new Error('Invalid local gateway endpoint')- }+ assertLocalGatewayEndpoint(endpoint)return { baseUrl: endpoint.api_origin, wsUrl: `${endpoint.api_origin.replace(/^http/, 'ws')}/api/ws?native_dial=unminted`, mode: 'local', source: 'local', authMode: 'native', token: '', gatewayEndpoint: endpoint }}diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 5fbe9aff51d..d6ca35ba6d4 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -12282,7 +12282,7 @@ async function startHermes(requestedProfile?: string) {// boundary when present, so the renderer overlay can key on it rather than// re-classifying the message string. main owns classification; the renderer// only consumes the structured result (#85335).- const isCloudBackendDown = Boolean(error && typeof error === 'object' && (error as any).isCloudBackendDown === true)+ const isCloudBackendDown = typeof error === 'object' && (error as any)?.isCloudBackendDown === trueconst statusCode = Number(error && typeof error === 'object' && Number.isInteger((error as any).statusCode)