From 0b1b9a913fc7030802bce78a400990bebd78cb51 Mon Sep 17 00:00:00 2001 From: icarus Date: Thu, 18 Sep 2025 18:02:05 +0800 Subject: [PATCH] feat(hooks): add useAgentClient hook for agent API client initialization --- src/renderer/src/hooks/agents/useAgentClient.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 src/renderer/src/hooks/agents/useAgentClient.ts diff --git a/src/renderer/src/hooks/agents/useAgentClient.ts b/src/renderer/src/hooks/agents/useAgentClient.ts new file mode 100644 index 0000000000..cd9b5638ba --- /dev/null +++ b/src/renderer/src/hooks/agents/useAgentClient.ts @@ -0,0 +1,15 @@ +import { AgentApiClient } from '@renderer/api/agent' + +import { useSettings } from '../useSettings' + +export const useAgentClient = () => { + const { apiServer } = useSettings() + const { host, port, apiKey } = apiServer + const client = new AgentApiClient({ + baseURL: `${host}:${port}`, + headers: { + Authorization: `Bearer ${apiKey}` + } + }) + return client +}