mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 04:11:35 +00:00
The checkout hand-off moved from main.ts into updater/checkout.ts during
the pm/ rewrite and dropped the remote-ownership rule from 04845f5f3e
(#117529): a Desktop in app-global remote/cloud/SSH mode owns no local
messaging gateway, but `hermes update --gateway` (re)started one on the
laptop anyway and, with the same channel credentials as the remote host,
it became a competing long-poll consumer. Both scripts still accept the
flag; only the Electron side stopped sending it.
The strategy now takes `remoteGatewayActive` from the shell (main.ts
wires globalRemoteActive) and pushes the flag on both arms.
41 lines
1.8 KiB
TypeScript
41 lines
1.8 KiB
TypeScript
import { expect, it, vi } from 'vitest'
|
|
|
|
import { type CheckoutStrategyDeps, createCheckoutStrategy } from './checkout'
|
|
import type { SourceUpdate } from './checkout-source'
|
|
|
|
it.each(['not-a-git-checkout', 'update-root-steward-owned-git-tree', 'fetch-failed'])(
|
|
'preserves the Python refusal or error before handoff: %s',
|
|
async (reason: string): Promise<void> => {
|
|
const status: SourceUpdate =
|
|
reason === 'fetch-failed' ? { supported: true, error: reason } : { supported: false, reason }
|
|
|
|
const deps: CheckoutStrategyDeps = {
|
|
readSourceUpdate: vi.fn(async (): Promise<SourceUpdate> => status),
|
|
hermesHome: 'home',
|
|
isWindows: process.platform === 'win32',
|
|
isMac: process.platform === 'darwin',
|
|
defaultUpdateBranch: 'main',
|
|
updateHandoffDwellMs: 0,
|
|
resolveUpdateRoot: (): string => 'repo',
|
|
resolveUpdaterBinary: vi.fn((): null => null),
|
|
remoteGatewayActive: (): boolean => false,
|
|
emitUpdateProgress: vi.fn(),
|
|
rememberLog: vi.fn(),
|
|
startHermes: vi.fn(async (): Promise<void> => {}),
|
|
stopBackendsForUpdate: vi.fn(async (): Promise<void> => {}),
|
|
repairMacUpdaterHelper: vi.fn(),
|
|
preflightStateDb: vi.fn(),
|
|
runningAppBundle: (): null => null,
|
|
markQuittingForHandoff: vi.fn(),
|
|
quit: vi.fn()
|
|
}
|
|
|
|
const strategy: ReturnType<typeof createCheckoutStrategy> = createCheckoutStrategy(deps)
|
|
expect(await strategy.check()).toMatchObject({ ...status, mechanism: strategy.mechanism })
|
|
expect(await strategy.apply()).toMatchObject({ ok: false, error: reason })
|
|
expect(deps.readSourceUpdate).toHaveBeenLastCalledWith('repo', { force: true })
|
|
expect(deps.resolveUpdaterBinary).not.toHaveBeenCalled()
|
|
expect(deps.stopBackendsForUpdate).not.toHaveBeenCalled()
|
|
expect(deps.quit).not.toHaveBeenCalled()
|
|
}
|
|
)
|