Skip to content

The agent that grows with you

fix(desktop): use payload Python for gateway tickets

KoNit-Kdbfdfe5ec159
diff --git a/apps/desktop/electron/local-gateway-python-runtime.test.ts b/apps/desktop/electron/local-gateway-python-runtime.test.ts
index 85091b42140..5afdabe2d06 100644
--- a/apps/desktop/electron/local-gateway-python-runtime.test.ts
+++ b/apps/desktop/electron/local-gateway-python-runtime.test.ts
@@ -24,6 +24,22 @@ test('a Python backend is the helper interpreter as-is', async () => {
await expect(ticketRuntimeFor(backend)).resolves.toBe(backend)
})
+test('a bundled launcher keeps its CLI command but names the payload Python for ticket minting', async () => {
+ const backend = {
+ command: '/resources/agent-payload/bin/hermes.exe',
+ kind: 'python',
+ shell: false,
+ env: { HERMES_RUNTIME_DIR: '/resources/agent-payload/tools' },
+ ticketCommand: '/resources/agent-payload/tools/python/python.exe',
+ ticketEnv: { PYTHONPATH: '/resources/agent-payload/repo;/resources/agent-payload/venv/Lib/site-packages' }
+ }
+
+ await expect(ticketRuntimeFor(backend)).resolves.toEqual({
+ command: backend.ticketCommand,
+ env: { ...backend.env, ...backend.ticketEnv }
+ })
+})
+
test.skipIf(process.platform === 'win32')('an installed launcher backend mints with the interpreter it reports', async () => {
// The normal Windows install resolves to kind 'command' (the installation launcher).
const python = process.execPath
diff --git a/apps/desktop/electron/local-gateway-python.ts b/apps/desktop/electron/local-gateway-python.ts
index 876a5380390..eb1c26650e3 100644
--- a/apps/desktop/electron/local-gateway-python.ts
+++ b/apps/desktop/electron/local-gateway-python.ts
@@ -164,6 +164,9 @@ interface ResolvedTicketBackend {
shell?: boolean
env?: NodeJS.ProcessEnv
root?: string
+ /** A bundled CLI still launches normally, but ticket minting needs its interpreter. */
+ ticketCommand?: string
+ ticketEnv?: NodeJS.ProcessEnv
}
const RUNTIME_COMMAND_TIMEOUT_MS = 30_000
@@ -222,6 +225,10 @@ function isFile(candidate: string): boolean {
* PYTHONPATH is its whole import closure (-P still keeps the cwd out).
*/
export async function ticketRuntimeFor(backend: ResolvedTicketBackend): Promise<{ command: string; env?: NodeJS.ProcessEnv }> {
+ if (backend.ticketCommand) {
+ return { command: backend.ticketCommand, env: { ...backend.env, ...backend.ticketEnv } }
+ }
+
if (backend.kind === 'python' && !backend.shell) {
return backend
}
diff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.ts
index b5a846f9cca..e937ceacb2f 100644
--- a/apps/desktop/electron/main.ts
+++ b/apps/desktop/electron/main.ts
@@ -5026,6 +5026,11 @@ async function resolveHermesBackend(backendArgs: string[]): Promise<ResolvedHerm
command: 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) },
root: payload.repoDir,
bootstrap: false,
shell: false,
@@ -5209,6 +5214,8 @@ interface ResolvedHermesBackend {
shell: boolean
local?: string
root?: string
+ ticketCommand?: string
+ ticketEnv?: NodeJS.ProcessEnv
installStamp?: Readonly<InstallStamp> | null
activeRoot?: string
isPackaged?: boolean