mirror of
https://github.com/stablyai/orca.git
synced 2026-11-14 01:47:24 +00:00
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>
37 lines
1.1 KiB
TypeScript
37 lines
1.1 KiB
TypeScript
import {
|
|
pairedRuntimeConnectionFromOffer,
|
|
type PairedRuntimeConnection
|
|
} from '../../shared/paired-runtime-connection'
|
|
import { parsePairingCode } from '../../shared/pairing'
|
|
import { resolveEnvironmentPairingOffer } from './environments'
|
|
import { RuntimeClientError } from './types'
|
|
|
|
export function resolveRemoteConnection(
|
|
userDataPath: string,
|
|
pairingCode: string | null,
|
|
environmentSelector: string | null
|
|
): PairedRuntimeConnection | null {
|
|
if (pairingCode && environmentSelector) {
|
|
throw new RuntimeClientError(
|
|
'invalid_argument',
|
|
'Use either --pairing-code or --environment, not both.'
|
|
)
|
|
}
|
|
if (environmentSelector) {
|
|
return pairedRuntimeConnectionFromOffer(
|
|
resolveEnvironmentPairingOffer(userDataPath, environmentSelector)
|
|
)
|
|
}
|
|
if (!pairingCode) {
|
|
return null
|
|
}
|
|
const pairing = parsePairingCode(pairingCode)
|
|
if (!pairing) {
|
|
throw new RuntimeClientError(
|
|
'invalid_argument',
|
|
'Invalid remote pairing code. Expected an orca://pair?... URL or bare pairing payload.'
|
|
)
|
|
}
|
|
return pairedRuntimeConnectionFromOffer(pairing)
|
|
}
|