The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
refactor(desktop): keep payload runtime helpers in payload-backend
Austin Pickettbe8c674744c7
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex e937ceacb2f..1eac74c94cd 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -417,7 +417,14 @@ import {import { wireOauthSessionResponse } from './oauth-session-response'import { listWindowsProcesses, reapPackageRootedProcesses } from './package-process-reap'import { createParentStartMarkerResolver } from './parent-process-identity'-import { bundledPayload, installIdForRoot, type PayloadInfo, payloadPythonPath } from './payload-backend'+import {+ bundledPayload,+ installIdForRoot,+ type PayloadInfo,+ payloadPythonPath,+ payloadTicketRuntime,+ requireBundledPayload+} from './payload-backend'import { petOverlayClickThrough, shouldPopInOnOverlayClosed } from './pet-overlay'import { placePetOverlay, registerPetOverlayIpc } from './pet-overlay-ipc'import {@@ -3674,21 +3681,6 @@ function createNativePackagedStrategy(return new ExternalStrategy(INSTALL_STAMP)}-/**- * The bundled Python payload for a strategy whose update check runs inside- * it. A stamp that names such a mechanism without a payload is a broken- * install; say so instead of failing on `payload.storePython`.- */-function requireBundledPayload(mechanism: UpdaterStrategy['mechanism']): PayloadInfo {- const payload: PayloadInfo | null = bundledPayload(process.resourcesPath)-- if (!payload) {- throw new Error(`${mechanism} updates require the bundled application payload, which this install has none of`)- }-- return payload-}-/*** The checkout updater strategy (windows-handoff / posix-handoff). The flow* lives in updater/checkout.ts; this is the composition root that hands it@@ -5026,11 +5018,7 @@ async function resolveHermesBackend(backendArgs: string[]): Promise<ResolvedHermcommand: payload.shim,args: [...backendArgs],env: { ...buildDesktopBackendEnv(), HERMES_RUNTIME_DIR: payload.toolsDir },- // The payload shim is the CLI entrypoint. TicketBridge instead runs a- // Python import helper, so it must use the payload interpreter and the- // same core/dependency path as the shim.- ticketCommand: payload.storePython,- ticketEnv: { PYTHONPATH: payloadPythonPath(payload) },+ ...payloadTicketRuntime(payload),root: payload.repoDir,bootstrap: false,shell: false,diff --git a/apps/desktop/electron/payload-backend.test.ts b/apps/desktop/electron/payload-backend.test.tsindex 4492fd2cca0..a52e83705ed 100644--- a/apps/desktop/electron/payload-backend.test.ts+++ b/apps/desktop/electron/payload-backend.test.ts@@ -6,7 +6,7 @@ import path from 'node:path'import { test, vi } from 'vitest'import type { InstallStamp, PayloadRuntime } from './install-stamp'-import { bundledPayload, installIdForRoot, payloadPythonPath } from './payload-backend'+import { bundledPayload, installIdForRoot, payloadPythonPath, payloadTicketRuntime } from './payload-backend'function stamp(runtime: PayloadRuntime, payload: InstallStamp['payload'] = 'bundled'): InstallStamp {return {@@ -66,6 +66,21 @@ test('bundled launch paths come from build metadata without filesystem access',}})+test('ticket minting runs the payload python, never the CLI shim', () => {+ const payload = {+ storePython: '/p/tools/python',+ repoDir: '/p/repo',+ sitePackages: '/p/venv/site-packages',+ shim: '/p/bin/hermes'+ }++ const runtime = payloadTicketRuntime(payload)++ assert.equal(runtime.ticketCommand, payload.storePython)+ assert.notEqual(runtime.ticketCommand, payload.shim)+ assert.deepEqual(runtime.ticketEnv, { PYTHONPATH: payloadPythonPath(payload) })+})+// ─── update channel helpers ─────────────────────────────────────────test('installIdForRoot matches the Python install id (sha16 of the canonical path)', () => {diff --git a/apps/desktop/electron/payload-backend.ts b/apps/desktop/electron/payload-backend.tsindex ba1c2a39f8e..a1398f8fe39 100644--- a/apps/desktop/electron/payload-backend.ts+++ b/apps/desktop/electron/payload-backend.ts@@ -46,6 +46,33 @@ export function payloadPythonPath(payload: Pick<PayloadInfo, 'repoDir' | 'sitePareturn [payload.repoDir, payload.sitePackages].join(path.delimiter)}+/**+ * The bundled shim is the Hermes CLI, not an interpreter, so it rejects the+ * ticket bridge's `-P -u -c`. Ticket minting runs the payload python against+ * the same import closure the shim gives the CLI.+ */+export function payloadTicketRuntime(payload: Pick<PayloadInfo, 'storePython' | 'repoDir' | 'sitePackages'>): {+ ticketCommand: string+ ticketEnv: NodeJS.ProcessEnv+} {+ return { ticketCommand: payload.storePython, ticketEnv: { PYTHONPATH: payloadPythonPath(payload) } }+}++/**+ * The bundled Python payload for a strategy whose update check runs inside+ * it. A stamp that names such a mechanism without a payload is a broken+ * install; say so instead of failing on `payload.storePython`.+ */+export function requireBundledPayload(mechanism: string, resourcesPath = process.resourcesPath): PayloadInfo {+ const payload: PayloadInfo | null = bundledPayload(resourcesPath)++ if (!payload) {+ throw new Error(`${mechanism} updates require the bundled application payload, which this install has none of`)+ }++ return payload+}+// ─── update channel ─────────────────────────────────────────────────────────//// The CLI owns the channel records; Electron only reads the install id for