mirror of
https://github.com/browseros-ai/BrowserOS.git
synced 2026-05-19 19:41:06 +00:00
git-subtree-dir: packages/browseros-agent git-subtree-mainline:8f148d0918git-subtree-split:90bd4be300
20 lines
530 B
TypeScript
20 lines
530 B
TypeScript
import type { AppType } from '@browseros/server'
|
|
import { hc } from 'hono/client'
|
|
import { getAgentServerUrl } from '../browseros/helpers'
|
|
|
|
export type RpcClient = ReturnType<typeof hc<AppType>>
|
|
|
|
let clientPromise: Promise<RpcClient> | null = null
|
|
|
|
export const getClient = (): Promise<RpcClient> => {
|
|
if (!clientPromise) {
|
|
clientPromise = getAgentServerUrl().then((serverUrl) =>
|
|
hc<AppType>(serverUrl),
|
|
)
|
|
}
|
|
return clientPromise
|
|
}
|
|
|
|
// Pre-resolve the client immediately when the module is imported
|
|
getClient()
|