Files
orca/tests/e2e/fixtures/daemon-generation-desktop-discovery.ts
Neil 2f217b4d0d refactor(daemon): group endpoint, provider, session and transport owners (#38462)
* refactor(daemon): group transport, provider, endpoint, and terminal owners

* refactor(daemon): consolidate owner imports and preserve pinned baseline sources

* refactor(daemon): import termination budgets from their defining owner

* fix(ci): retain serve mode coverage for extracted orcad startup

* fix daemon build smoke to load concrete argument owner

* read daemon protocol facts from historical defining paths

* route protocol revision owners through compatibility checks
2026-11-05 01:54:51 -08:00

45 lines
2.0 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { DaemonPtyAdapter } from '../../../src/main/daemon/providers/adapter/daemon-pty-adapter'
import { createLegacyDaemonAdapters } from '../../../src/main/daemon/providers/routing/daemon-legacy-adapters'
import { DaemonPtyRouter } from '../../../src/main/daemon/providers/routing/daemon-pty-router'
export type DesktopDiscoveryGeneration = {
protocolVersion: number
socketPath: string
tokenPath: string
}
export async function createDesktopDiscoveredDaemonRouter(options: {
generations: readonly DesktopDiscoveryGeneration[]
currentProtocolVersion: number
daemonDir: string
historyDir: string
}): Promise<{ router: DaemonPtyRouter; adapters: readonly DaemonPtyAdapter[] }> {
const currentGeneration = options.generations.find(
(generation) => generation.protocolVersion === options.currentProtocolVersion
)
if (!currentGeneration) {
throw new Error(`Missing current protocol v${options.currentProtocolVersion} fixture`)
}
const current = new DaemonPtyAdapter({
socketPath: currentGeneration.socketPath,
tokenPath: currentGeneration.tokenPath,
protocolVersion: currentGeneration.protocolVersion,
historyPath: options.historyDir
})
// Exercise the production startup scanner’s versioned-pipe discovery and legacy-adapter construction.
const legacy = await createLegacyDaemonAdapters(options.daemonDir, options.historyDir)
const discoveredProtocols = legacy.map((adapter) => adapter.protocolVersion)
const expectedProtocols = options.generations
.filter((generation) => generation.protocolVersion !== options.currentProtocolVersion)
.map((generation) => generation.protocolVersion)
if (JSON.stringify(discoveredProtocols) !== JSON.stringify(expectedProtocols)) {
throw new Error(
`Desktop legacy discovery mismatch: expected ${expectedProtocols.join(',')}, received ${discoveredProtocols.join(',')}`
)
}
return {
router: new DaemonPtyRouter({ current, legacy }),
adapters: [current, ...legacy]
}
}