import { AgentApiClient } from '@renderer/api/agent'
import { useMemo } from 'react'

import { useSettings } from '../useSettings'

export const useAgentClient = () => {
  const { apiServer } = useSettings()
  const { host, port, apiKey } = apiServer
  return useMemo(
    () =>
      new AgentApiClient({
        baseURL: `http://${host}:${port}`,
        headers: {
          Authorization: `Bearer ${apiKey}`
        }
      }),
    [host, port, apiKey]
  )
}
