-
Notifications
You must be signed in to change notification settings - Fork 157
Expand file tree
/
Copy pathA2AClientProvider.tsx
More file actions
43 lines (34 loc) · 1.11 KB
/
A2AClientProvider.tsx
File metadata and controls
43 lines (34 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
/**
* Copyright 2025 © BeeAI a Series of LF Projects, LLC
* SPDX-License-Identifier: Apache-2.0
*/
'use client';
import type { PropsWithChildren } from 'react';
import { useMemo } from 'react';
import type { Agent } from '#modules/agents/api/types.ts';
import { useContextToken } from '#modules/platform-context/api/queries/useContextToken.ts';
import { useBuildA2AClient } from '#modules/runs/api/queries/useBuildA2AClient.ts';
import { A2AClientContext } from './a2a-client-context';
interface Props {
agent: Agent;
}
export function A2AClientProvider({ agent, children }: PropsWithChildren<Props>) {
const { data: contextToken } = useContextToken(agent);
const { agentClient } = useBuildA2AClient({
providerId: agent.provider.id,
authToken: contextToken,
});
const contextValue = useMemo(() => {
if (!contextToken || !agentClient) {
return null;
}
return {
contextToken,
agentClient,
};
}, [contextToken, agentClient]);
if (!contextValue) {
return null;
}
return <A2AClientContext.Provider value={contextValue}>{children}</A2AClientContext.Provider>;
}