Files
orca/src/main/ipc/runtime-environment-shared-control-support.ts
T
OrcaWinandm4air 34e2e5f469 refactor(remote): clients connect through a paired-connection handle, not a pairing offer (#27533)
Desktop, CLI, web and runtime transports now take a PairedRuntimeConnection
(endpoint, pinned host key, credential) instead of a PairingOffer. Offers stay on
the pairing input path (codes, QR, links, environment add) and are converted with
pairedRuntimeConnectionFromOffer. The credential is token-only today; request
envelopes still carry the same deviceToken, so the wire is unchanged.

This lets device-key and ticket credentials replace the token later without
touching every connect call site again.

Co-authored-by: m4air <m4air@Mac.localdomain>
2026-10-11 14:02:03 -07:00

47 lines
1.5 KiB
TypeScript

import type { PairedRuntimeConnection } from '../../shared/paired-runtime-connection'
import type { KnownRuntimeEnvironment } from '../../shared/runtime-environments'
import { RemoteRuntimeClientError } from '../../shared/remote-runtime-client-error'
import {
getAcceptedRuntimeEnvironmentCapabilityOutcome,
resetRuntimeEnvironmentCapabilityEvidence,
type RuntimeEnvironmentCapabilityOutcome
} from './runtime-environment-capability-evidence'
import {
getRuntimeEnvironmentStatusOwner,
resetRuntimeEnvironmentStatusOwners
} from './runtime-environment-request-connections'
export function resetSharedControlSupport(): void {
resetRuntimeEnvironmentStatusOwners()
resetRuntimeEnvironmentCapabilityEvidence()
}
export async function supportsSharedControl(
userDataPath: string,
environment: KnownRuntimeEnvironment,
connection: PairedRuntimeConnection,
timeoutMs: number
): Promise<RuntimeEnvironmentCapabilityOutcome> {
const accepted = getAcceptedRuntimeEnvironmentCapabilityOutcome(
environment.id,
connection,
environment.runtimeId
)
if (accepted) {
return accepted
}
const response = await getRuntimeEnvironmentStatusOwner(userDataPath, environment.id).refresh({
timeoutMs
})
if (!response.ok) {
throw new RemoteRuntimeClientError(response.error.code, response.error.message)
}
return (
getAcceptedRuntimeEnvironmentCapabilityOutcome(
environment.id,
connection,
response._meta.runtimeId
) ?? { kind: 'stale_incarnation' }
)
}