refactor: migrate from clientSessionKey to clientId identity

This commit is contained in:
Mohamed Boudra
2026-02-21 15:33:29 +07:00
parent e906bffbb9
commit c3c8103563
56 changed files with 3289 additions and 941 deletions
+12 -9
View File
@@ -1,6 +1,6 @@
import { DaemonClient } from '@getpaseo/server'
import WebSocket from 'ws'
import { getOrCreateCliClientSessionKey } from './client-session-key.js'
import { getOrCreateCliClientId } from './client-id.js'
export interface ConnectOptions {
host?: string
@@ -40,15 +40,18 @@ function createNodeWebSocketFactory() {
export async function connectToDaemon(options?: ConnectOptions): Promise<DaemonClient> {
const host = getDaemonHost(options)
const timeout = options?.timeout ?? DEFAULT_TIMEOUT
const clientSessionKey = await getOrCreateCliClientSessionKey()
const encodedSessionKey = encodeURIComponent(clientSessionKey)
const url = `ws://${host}/ws?clientSessionKey=${encodedSessionKey}`
const clientId = await getOrCreateCliClientId()
const url = `ws://${host}/ws`
const client = new DaemonClient({
url,
webSocketFactory: createNodeWebSocketFactory(),
reconnect: { enabled: false },
})
const client = new DaemonClient(
{
url,
clientId,
clientType: 'cli',
webSocketFactory: createNodeWebSocketFactory(),
reconnect: { enabled: false },
} as unknown as ConstructorParameters<typeof DaemonClient>[0]
)
// Connect with timeout
const connectPromise = client.connect()