feat(servers): harden pairing and run linked-server sessions in the UI

Replace the plaintext pairing exchange with a nonce and HMAC proof plus
AES-256-GCM encrypted credentials, bumping links to v2. Track session
ownership per linked server so activity, session picker, transcript, MCP
and skills views work against remote servers. Share encrypted secret
access, event routing and URL helpers across backend, shared and CLI.
This commit is contained in:
Chris Scott committed 2026-10-18 20:27:34 -04:00
1 parent c591c15743
commit f566556fd6
77 files changed
+3170 -702

No files matched your search

+22 -4
View File
@@ -1,4 +1,7 @@
import { OpenCode } from '@opencode/client'
import { OPENCODE_SERVER_USERNAME } from '../schemas/opencode-servers'
export { OPENCODE_SERVER_USERNAME }
export type {
AgentInfo,
@@ -92,6 +95,23 @@ export type {
McpTimeoutConfig,
} from './mcp'
export {
createOpenCodePairingNonce,
createOpenCodePairingProof,
decryptOpenCodePairingCredentials,
encryptOpenCodePairingCredentials,
isOpenCodePairingCredentials,
isOpenCodePairingNonce,
verifyOpenCodePairingProof,
} from './pairing'
export type {
OpenCodePairingCredentials,
OpenCodePairingDecryptOptions,
OpenCodePairingEncryptedCredentials,
OpenCodePairingKeyOptions,
} from './pairing'
export {
OPENCODE_PINNED_VERSION,
OPENCODE_SUPPORTED_VERSION_RANGE,
@@ -109,8 +129,6 @@ export { OPENCODE_LIFECYCLE_STATES, OPENCODE_RECOVERY_ACTIONS } from './lifecycl
export type { OpenCodeLifecycleState, OpenCodeLifecycleStatus, OpenCodeRecoveryAction } from './lifecycle'
export const OPENCODE_SERVER_USERNAME = 'opencode'
export type OpenCodeApi = ReturnType<typeof OpenCode.make>
export interface OpenCodeApiOptions {
@@ -120,8 +138,8 @@ export interface OpenCodeApiOptions {
headers?: Record<string, string>
}
export function buildOpenCodeBasicAuth(password: string): string {
const bytes = new TextEncoder().encode(`${OPENCODE_SERVER_USERNAME}:${password}`)
export function buildOpenCodeBasicAuth(password: string, username: string = OPENCODE_SERVER_USERNAME): string {
const bytes = new TextEncoder().encode(`${username}:${password}`)
let binary = ''
for (const byte of bytes) binary += String.fromCharCode(byte)
return `Basic ${btoa(binary)}`