The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(desktop): reuse bounded native ticket helpers
David Dudok de Witacb54ba2ee6e
diff --git a/apps/desktop/electron/local-gateway-python-native.test.ts b/apps/desktop/electron/local-gateway-python-native.test.tsnew file mode 100644index 00000000000..394ff9ba280--- /dev/null+++ b/apps/desktop/electron/local-gateway-python-native.test.ts@@ -0,0 +1,85 @@+import { spawn } from 'node:child_process'+import type * as ChildProcessAPI from 'node:child_process'+import { once } from 'node:events'+import fs from 'node:fs/promises'+import os from 'node:os'+import path from 'node:path'++import { expect, test, vi } from 'vitest'++import { closeGatewayTicketBridges, createGatewayTicketResolver } from './local-gateway-python'++const observed = vi.hoisted(() => ({ helpers: 0 }))+vi.mock('node:child_process', async importOriginal => {+ const actual = await importOriginal<typeof ChildProcessAPI>()++ return { ...actual, spawn: (...args: Parameters<typeof actual.spawn>) => {+ if (Array.isArray(args[1]) && args[1][0] === '-P') { observed.helpers++ }++ return actual.spawn(...args)+ } }+})++test.skipIf(process.platform !== 'win32')('native pipe tickets reuse one helper and revalidate every owner', async () => {+ const home = await fs.realpath(await fs.mkdtemp(path.join(os.tmpdir(), 'ticket-bridge-')))+ const root = path.resolve(import.meta.dirname, '../../..')+ const python = process.env.HERMES_TEST_PYTHON || 'python'+ const env = { ...process.env, PYTHONPATH: root, HERMES_HOME: home, PYTHONUTF8: '1' }++ const code = `+import json, sys+from pathlib import Path+from gateway.runtime_bootstrap_windows import NativeControlServer+counter = 0+def handle(raw, subject):+ global counter+ request = json.loads(raw)+ if request['params']['instance_id'] == 'refused':+ return json.dumps({'protocol':1, 'id':1, 'ok':False}).encode() + b'\\n'+ counter += 1+ return json.dumps({'protocol':1, 'id':1, 'ok':True, 'result':{+ 'profile_id':str(Path(sys.argv[1]).resolve()), 'instance_id':'owner',+ 'runtime_protocol':1, 'ticket':f'grant-{counter}'}}).encode() + b'\\n'+server = NativeControlServer(Path(sys.argv[1]), handle)+server.start()+print('ready', flush=True)+try:+ sys.stdin.read()+finally:+ server.close()+`++ const server = spawn(python, ['-c', code, home], { env, windowsHide: true, stdio: ['pipe', 'pipe', 'pipe'] })+ server.stderr.resume()++ try {+ await once(server.stdout, 'data')+ const endpoint = { profile_id: home, instance_id: 'owner', runtime_protocol: 1, control_home: null }+ const resolveBackend = vi.fn(async () => ({ command: python, env, kind: 'python', shell: false }))+ const mint = createGatewayTicketResolver(resolveBackend, () => root)+ const before = observed.helpers++ const [first, second] = await Promise.all([+ mint(endpoint, 'interactive'),+ mint(endpoint, 'native-http')+ ])++ expect(first).not.toBe(second)+ expect(observed.helpers - before).toBe(1)+ expect(resolveBackend).toHaveBeenCalledOnce()+ await expect(mint({ ...endpoint, instance_id: 'stale' }, 'interactive')).rejects.toThrow('Gateway ticket')+ await expect(mint({ ...endpoint, instance_id: 'refused' }, 'interactive')).rejects.toMatchObject({ reason: 'invalid_control_response' })+ await expect(mint(endpoint, 'interactive')).resolves.toMatch(/^grant-/)+ expect(observed.helpers - before).toBe(1)+ closeGatewayTicketBridges()+ await expect(mint(endpoint, 'native-http')).resolves.toMatch(/^grant-/)+ expect(observed.helpers - before).toBe(2)+ expect(resolveBackend).toHaveBeenCalledTimes(2)+ } finally {+ closeGatewayTicketBridges()+ const stopped = once(server, 'close')+ server.stdin.end()+ await stopped+ await fs.rm(home, { recursive: true, force: true })+ }+}, 60_000)diff --git a/apps/desktop/electron/local-gateway-python.test.ts b/apps/desktop/electron/local-gateway-python.test.tsindex b59a431d6cd..47b4df301b9 100644--- a/apps/desktop/electron/local-gateway-python.test.ts+++ b/apps/desktop/electron/local-gateway-python.test.ts@@ -5,7 +5,7 @@ import path from 'node:path'import { expect, test } from 'vitest'-import { mintGatewayTicketWithPython } from './local-gateway-python'+import { closeGatewayTicketBridges, mintGatewayTicketWithPython } from './local-gateway-python'// This exercises the real helper process and protocol on this host. The native// probe separately exercises Windows SID checks and HTTP/WS admission.@@ -87,6 +87,7 @@ test.skipIf(process.platform === 'win32')('Python ticket bridge pins profile, owawait expect(mintGatewayTicketWithPython(backend, cwd, { ...endpoint, control_home: mux }, 'interactive')).resolves.toBe('private-grant')expect(requests.at(-1).params).toEqual({ profile_id: home, instance_id: 'owner', purpose: 'interactive' })} finally {+ closeGatewayTicketBridges()await new Promise<void>(resolve => server.close(() => resolve()))await fs.rm(home, { recursive: true, force: true })await fs.rm(mux, { recursive: true, force: true })diff --git a/apps/desktop/electron/local-gateway-python.ts b/apps/desktop/electron/local-gateway-python.tsindex a3d1485791d..39a9baad08b 100644--- a/apps/desktop/electron/local-gateway-python.ts+++ b/apps/desktop/electron/local-gateway-python.ts@@ -1,4 +1,4 @@-import { spawn } from 'node:child_process'+import { type ChildProcessWithoutNullStreams, spawn } from 'node:child_process'import { hiddenWindowsChildOptions } from './windows-child-options'@@ -10,81 +10,205 @@ interface TicketEndpoint {control_home?: string | null}-// Reuse the runtime's SID-validated, deadline-bounded pipe client. No Node pipe-// connection may bypass GetNamedPipeServerProcessId / token-owner validation.-// POSIX: the profile home gets the full home policy (private-group + ACL proof that Node cannot-// make); the control home is checked again by connect_private. A refusal reports its reason.+// Reuse the runtime's bounded control client: POSIX home/ACL/socket checks and+// Windows pipe server PID/SID validation have one canonical implementation.const TICKET_SCRIPT = `import json, os, sys+from contextlib import redirect_stdoutfrom pathlib import Pathfrom types import SimpleNamespace-from hermes_cli.gateway_client import _session_ticket-from hermes_cli.gateway_runtime_discovery import DiscoveryError, _private_node-request = json.loads(sys.stdin.buffer.read(65537))-endpoint = SimpleNamespace(**{'control_home': None, **request['endpoint']})-home = Path(endpoint.profile_id)-if str(home.resolve()) != endpoint.profile_id or endpoint.runtime_protocol != 1:- raise ValueError('invalid ticket endpoint')-try:- if os.name != 'nt':- _private_node(home, kind='directory', home=True)- ticket = _session_ticket(home, endpoint, purpose=request['purpose'])-except DiscoveryError as exc:- sys.stdout.write(json.dumps({'error': exc.reason}))- sys.exit(3)-sys.stdout.write(json.dumps({'ticket': ticket}))+with redirect_stdout(sys.stderr):+ from hermes_cli.gateway_client import _session_ticket+ from hermes_cli.gateway_runtime_discovery import DiscoveryError, _private_node+while True:+ line = sys.stdin.buffer.readline(65537)+ if not line:+ break+ if len(line) > 65536 or not line.endswith(b'\\n'):+ break+ request = json.loads(line)+ try:+ with redirect_stdout(sys.stderr):+ endpoint = SimpleNamespace(**{'control_home': None, **request['endpoint']})+ home = Path(endpoint.profile_id)+ if str(home.resolve()) != endpoint.profile_id or endpoint.runtime_protocol != 1:+ raise ValueError('invalid ticket endpoint')+ if os.name != 'nt':+ _private_node(home, kind='directory', home=True)+ ticket = _session_ticket(home, endpoint, purpose=request['purpose'])+ reply = {'id': request['id'], 'ticket': ticket}+ except DiscoveryError as exc:+ reply = {'id': request['id'], 'error': exc.reason}+ except Exception:+ reply = {'id': request['id'], 'error': 'ticket_failed'}+ print(json.dumps(reply), flush=True)`-export function mintGatewayTicketWithPython(- backend: { command: string; env?: NodeJS.ProcessEnv },- cwd: string,- endpoint: TicketEndpoint,- purpose: 'interactive' | 'native-http'-): Promise<string> {- return new Promise((resolve, reject) => {- const child = spawn(backend.command, ['-P', '-c', TICKET_SCRIPT], hiddenWindowsChildOptions({- cwd,- env: { ...process.env, ...backend.env, HERMES_HOME: endpoint.profile_id, PYTHONIOENCODING: 'utf-8', PYTHONUTF8: '1' },- shell: false,- stdio: ['pipe', 'pipe', 'pipe']+interface PendingTicket {+ resolve: (ticket: string) => void+ reject: (error: Error) => void+ timer: ReturnType<typeof setTimeout>+}++const bridges = new Map<string, TicketBridge>()+let bridgeGeneration = 0++/** Reuse one private helper per runtime/profile; every ticket still verifies the live owner. */+class TicketBridge {+ private child: ChildProcessWithoutNullStreams+ private pending = new Map<number, PendingTicket>()+ private sequence = 0+ private output = ''+ private idleTimer?: ReturnType<typeof setTimeout>+ private closed = false++ constructor(command: string, cwd: string, env: NodeJS.ProcessEnv, private key: string) {+ this.child = spawn(command, ['-P', '-u', '-c', TICKET_SCRIPT], hiddenWindowsChildOptions({+ cwd, env, shell: false, stdio: ['pipe', 'pipe', 'pipe']}))+ this.child.stderr.resume()+ this.child.stdout.setEncoding('utf8')+ this.child.stdout.on('data', data => this.receive(String(data)))+ this.child.on('error', () => this.dispose())+ this.child.stdin.on('error', () => this.dispose())+ this.child.on('close', () => this.dispose())+ }- let stdout = ''+ request(endpoint: TicketEndpoint, purpose: 'interactive' | 'native-http'): Promise<string> {+ clearTimeout(this.idleTimer)- const fail = () => {- let reason: unknown+ return new Promise((resolve, reject) => {+ if (this.closed) { reject(new Error('Gateway ticket bootstrap failed'));- try { reason = JSON.parse(stdout).error } catch { reason = undefined }- reject(Object.assign(new Error('Gateway ticket bootstrap failed'), typeof reason === 'string' ? { reason } : {}))- }+ return }- const timer = setTimeout(() => { child.kill(); fail() }, 10_000)- child.on('error', fail)- child.stdin.on('error', fail)- child.stderr.resume()- child.stdout.setEncoding('utf8')- child.stdout.on('data', data => {- stdout += data+ const id = ++this.sequence+ const request = JSON.stringify({ id, endpoint, purpose }) + '\n'- if (stdout.length > 65536) { child.kill(); fail() }+ if (Buffer.byteLength(request) > 65536) { reject(new Error('Gateway ticket request too large'));++ return }++ const timer = setTimeout(() => this.dispose(), 10_000)+ this.pending.set(id, { resolve, reject, timer })+ // Private stdin carries identity as data. EOF also retires the helper if Desktop exits.+ this.child.stdin.write(request)})- child.on('close', code => {- clearTimeout(timer)+ }++ private receive(data: string): void {+ this.output += data- if (code !== 0) {- fail()+ if (this.output.length > 65536) { this.dispose();- return- }+ return }++ let end: number++ while ((end = this.output.indexOf('\n')) >= 0) {+ const line = this.output.slice(0, end)+ this.output = this.output.slice(end + 1)try {- const reply = JSON.parse(stdout)+ const reply = JSON.parse(line)+ const waiter = this.pending.get(reply.id)- if (typeof reply.ticket !== 'string' || !reply.ticket) { throw new Error() }- resolve(reply.ticket)- } catch { fail() }- })- // Identity is data on private stdin, never interpolated into code or a shell.- child.stdin.end(JSON.stringify({ endpoint, purpose }))- })+ if (!waiter) { this.dispose();++ return }++ this.pending.delete(reply.id)+ clearTimeout(waiter.timer)++ if (typeof reply.ticket === 'string' && reply.ticket) { waiter.resolve(reply.ticket) }+ else { waiter.reject(Object.assign(new Error('Gateway ticket bootstrap failed'),+ typeof reply.error === 'string' ? { reason: reply.error } : {})) }+ } catch { this.dispose();++ return }+ }++ if (!this.pending.size) { this.idleTimer = setTimeout(() => this.dispose(), 30_000) }+ }++ dispose(): void {+ if (this.closed) { return }+ this.closed = true+ clearTimeout(this.idleTimer)++ if (bridges.get(this.key) === this) { bridges.delete(this.key) }++ for (const waiter of this.pending.values()) {+ clearTimeout(waiter.timer)+ waiter.reject(new Error('Gateway ticket bootstrap failed'))+ }++ this.pending.clear()+ this.child.kill('SIGKILL')+ }+}++export function closeGatewayTicketBridges(): void {+ bridgeGeneration++++ for (const bridge of bridges.values()) { bridge.dispose() }+}++interface ResolvedTicketBackend {+ command: string+ kind: string+ shell?: boolean+ env?: NodeJS.ProcessEnv+}++export function createGatewayTicketResolver(resolveBackend: () => Promise<ResolvedTicketBackend>, cwd: () => string) {+ let cached: Promise<ResolvedTicketBackend> | undefined+ let cachedGeneration = -1++ return async (endpoint: TicketEndpoint, purpose: 'interactive' | 'native-http'): Promise<string> => {+ const generation = bridgeGeneration++ if (!cached || cachedGeneration !== generation) {+ cachedGeneration = generation++ const flight = resolveBackend().then(backend => {+ if (backend.kind !== 'python' || backend.shell) {+ throw new Error('Gateway ticket bootstrap requires the installed Hermes Python runtime')+ }++ return backend+ }).catch(error => {+ if (cached === flight) { cached = undefined }+ throw error+ })++ cached = flight+ }++ const backend = await cached++ if (generation !== bridgeGeneration) { throw new Error('Gateway ticket runtime changed; retry connection') }++ return mintGatewayTicketWithPython(backend, cwd(), endpoint, purpose)+ }+}++export function mintGatewayTicketWithPython(+ backend: { command: string; env?: NodeJS.ProcessEnv },+ cwd: string,+ endpoint: TicketEndpoint,+ purpose: 'interactive' | 'native-http'+): Promise<string> {+ const env = { ...process.env, ...backend.env, HERMES_HOME: endpoint.profile_id,+ PYTHONIOENCODING: 'utf-8', PYTHONUTF8: '1' }++ const key = JSON.stringify([backend.command, cwd, Object.entries(env).sort(([a], [b]) => a.localeCompare(b))])+ let bridge = bridges.get(key)++ if (!bridge) {+ bridge = new TicketBridge(backend.command, cwd, env, key)+ bridges.set(key, bridge)+ }++ return bridge.request(endpoint, purpose)}diff --git a/apps/desktop/electron/local-gateway.test.ts b/apps/desktop/electron/local-gateway.test.tsindex 9c114f27734..56e63b2f2b7 100644--- a/apps/desktop/electron/local-gateway.test.ts+++ b/apps/desktop/electron/local-gateway.test.ts@@ -1,3 +1,5 @@+import path from 'node:path'+import { expect, test, vi } from 'vitest'import { createLocalGatewayDials, ensureLocalGateway, routedGatewayEndpoint, runGatewayEnsure } from './local-gateway'@@ -7,12 +9,14 @@ test('the ensure client inherits the caller-scrubbed parent env, not the raw Des// credentials. The parent env passed in IS the environment; only HERMES_HOME and the// backend's own entries are layered on top.const printEnv = ['-e', 'process.stdout.write(JSON.stringify({ leak: process.env.LEAK ?? null, home: process.env.HERMES_HOME, own: process.env.OWN }))']+const result = await runGatewayEnsure({ command: process.execPath, args: printEnv, env: { OWN: '1' }, shell: false },process.cwd(),'/home/x/.hermes',{ PATH: process.env.PATH ?? '', OWN: '0' })+expect(JSON.parse(result.stdout)).toEqual({ leak: null, home: '/home/x/.hermes', own: '1' })})@@ -52,7 +56,7 @@ test('canonical ensure cannot cross a rejected update or profile lifecycle gate'expect(ran).toBe(false)})-test.skipIf(process.platform === 'win32')('native HTTP mints fresh purpose-bound grants without browser credentials', async () => {+test.skipIf(process.platform === 'win32').each([0o700, 0o750, 0o701])('native HTTP respects supported home mode %o and mints fresh purpose-bound grants', async mode => {const fs = await import('node:fs/promises')const os = await import('node:os')const path = await import('node:path')@@ -61,13 +65,14 @@ test.skipIf(process.platform === 'win32')('native HTTP mints fresh purpose-bound// macOS: os.tmpdir() is /var/..., a symlink to /private/var; the gateway canonicalises// profile_id, so the endpoint must carry the realpath or identities never match.const home = await fs.realpath(await fs.mkdtemp(path.join(os.tmpdir(), 'desktop-http-')))+ await fs.chmod(home, mode)const endpoint = { profile_id: home, instance_id: 'owner', authority_epoch: 1, runtime_protocol: 1, api_origin: 'http://127.0.0.1:1234', capabilities: ['session-authority-v1'], supervisor: 'none' }const requests: any[] = []const server = net.createServer(socket => socket.once('data', chunk => {const request = JSON.parse(chunk.toString())requests.push(request)- socket.end(JSON.stringify({ protocol: 1, id: 1, ok: true, result: { profile_id: home, instance_id: 'owner', ticket: `grant-${requests.length}` } }) + '\n')+ socket.end(JSON.stringify({ protocol: 1, id: 1, ok: true, result: { profile_id: home, instance_id: 'owner', runtime_protocol: 1, ticket: `grant-${requests.length}` } }) + '\n')}))await new Promise<void>(resolve => server.listen(path.join(home, 'gateway.sock'), resolve))@@ -103,7 +108,7 @@ test.skipIf(process.platform === 'win32')('a served secondary mints its ticket tconst server = net.createServer(socket => socket.once('data', chunk => {requests.push(JSON.parse(chunk.toString()).params)- socket.end(JSON.stringify({ protocol: 1, id: 1, ok: true, result: { profile_id: secondary, instance_id: 'mux', ticket: 'served-grant' } }) + '\n')+ socket.end(JSON.stringify({ protocol: 1, id: 1, ok: true, result: { profile_id: secondary, instance_id: 'mux', runtime_protocol: 1, ticket: 'served-grant' } }) + '\n')}))await new Promise<void>(resolve => server.listen(path.join(root, 'gateway.sock'), resolve))@@ -227,7 +232,7 @@ test.skipIf(process.platform === 'win32')('a stopped gateway that unlinked its cconst serve = async (ticket: string) => {const server = net.createServer(socket => socket.once('data', () => {- socket.end(JSON.stringify({ protocol: 1, id: 1, ok: true, result: { profile_id: home, instance_id: 'owner', ticket } }) + '\n')+ socket.end(JSON.stringify({ protocol: 1, id: 1, ok: true, result: { profile_id: home, instance_id: 'owner', runtime_protocol: 1, ticket } }) + '\n')}))await new Promise<void>(resolve => server.listen(socketPath, resolve))@@ -393,11 +398,11 @@ test.skipIf(process.platform === 'win32')('a supported home mode mints its ticke})test('a ?profile= request on the shared host descriptor mints for the sibling profile home', () => {- const endpoint = { profile_id: '/h/.hermes', instance_id: 'i', authority_epoch: 1, runtime_protocol: 1, api_origin: 'http://127.0.0.1:1', capabilities: [], supervisor: 'none', control_home: null }- expect(routedGatewayEndpoint(endpoint, 'http://127.0.0.1:1/api/sessions?profile=p2', '/h/.hermes')).toMatchObject({ profile_id: '/h/.hermes/profiles/p2', control_home: '/h/.hermes' })- expect(routedGatewayEndpoint(endpoint, 'http://127.0.0.1:1/api/sessions?profile=default', '/h/.hermes')).toBe(endpoint)- expect(routedGatewayEndpoint({ ...endpoint, profile_id: '/h/.hermes/profiles/p2', control_home: '/h/.hermes' }, 'http://127.0.0.1:1/x?profile=default', '/h/.hermes')).toMatchObject({ profile_id: '/h/.hermes' })- expect(() => routedGatewayEndpoint(endpoint, 'http://127.0.0.1:1/x?profile=../evil', '/h/.hermes')).toThrow('Invalid profile route')+ const endpoint = { profile_id: path.resolve('hermes-home'), instance_id: 'i', authority_epoch: 1, runtime_protocol: 1, api_origin: 'http://127.0.0.1:1', capabilities: [], supervisor: 'none', control_home: null }+ expect(routedGatewayEndpoint(endpoint, 'http://127.0.0.1:1/api/sessions?profile=p2', path.resolve('hermes-home'))).toMatchObject({ profile_id: path.resolve('hermes-home', 'profiles', 'p2'), control_home: path.resolve('hermes-home') })+ expect(routedGatewayEndpoint(endpoint, 'http://127.0.0.1:1/api/sessions?profile=default', path.resolve('hermes-home'))).toBe(endpoint)+ expect(routedGatewayEndpoint({ ...endpoint, profile_id: path.resolve('hermes-home', 'profiles', 'p2'), control_home: path.resolve('hermes-home') }, 'http://127.0.0.1:1/x?profile=default', path.resolve('hermes-home'))).toMatchObject({ profile_id: path.resolve('hermes-home') })+ expect(() => routedGatewayEndpoint(endpoint, 'http://127.0.0.1:1/x?profile=../evil', path.resolve('hermes-home'))).toThrow('Invalid profile route')})// A native gateway grant is minted only by main's shared transport (fetchJsonForBackend), whichdiff --git a/apps/desktop/electron/main.ts b/apps/desktop/electron/main.tsindex 954f1fe21d7..bd04d88fb02 100644--- a/apps/desktop/electron/main.ts+++ b/apps/desktop/electron/main.ts@@ -2,17 +2,10 @@ import { type ChildProcess, execFileSync, spawn } from 'node:child_process'import type { GatewayEndpoint } from './local-gateway'import { configurePythonGatewayTicketClient, createLocalGatewayDials, createStaleGatewayRestarter, ensureLocalGateway, gatewayOwnerProfile, mintLocalGatewayTicket, nativeGatewayHttpHeaders, redialLocalGateway, routedGatewayEndpoint, runGatewayEnsure } from './local-gateway'-import { mintGatewayTicketWithPython } from './local-gateway-python'+import { closeGatewayTicketBridges, createGatewayTicketResolver } from './local-gateway-python'const localGatewayDials = createLocalGatewayDials()-configurePythonGatewayTicketClient(async (endpoint, purpose) => {- const backend = await ensureRuntime(await resolveHermesBackend([]), () => undefined)-- if (backend.kind !== 'python' || backend.shell) {- throw new Error('Gateway ticket bootstrap requires the installed Hermes Python runtime')- }-- return mintGatewayTicketWithPython(backend, resolveHermesCwd(), endpoint, purpose)-})+configurePythonGatewayTicketClient(createGatewayTicketResolver(+ async () => ensureRuntime(await resolveHermesBackend([]), () => undefined), resolveHermesCwd))import crypto from 'node:crypto'import fs from 'node:fs'import http from 'node:http'@@ -4401,6 +4394,8 @@ function reapOrphanedBackendsOnce() {// PM generations can retain live readers. Gateway draining/restart belongs to// `hermes update`; neither venv scans nor a second fleet stop belong here.async function stopBackendsForUpdate(): Promise<void> {+ closeGatewayTicketBridges()+if (IS_WINDOWS) {await Promise.all([teardownPrimaryBackendAndWait(backendTeardownOptions('reconnect')), stopAllPoolBackends()])}@@ -4409,6 +4404,8 @@ async function stopBackendsForUpdate(): Promise<void> {// Uninstall still deletes the installation and its historical venv. Unlike// generation updates, deletion must wait for those old files to be released.async function releaseBackendLock(updateRoot: string, tag: string): Promise<{ unlocked: boolean }> {+ closeGatewayTicketBridges()+if (!IS_WINDOWS) {return { unlocked: true }}@@ -17037,6 +17034,7 @@ app.on('before-quit', () => {// Close the pooled keep-alive sockets on quit so lingering connections can't// hold the event loop open or leak FDs past app teardown.app.on('will-quit', () => {+ closeGatewayTicketBridges()killTimedGitChildren()sshIsolatedKeepalives.stopAll()destroyKeepaliveAgents()