mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-03-13 07:30:52 -07:00
fix(a2a): simplify card resolution and fix redundant fetching
This commit is contained in:
@@ -60,8 +60,8 @@ describe('A2AClientManager', () => {
|
||||
|
||||
beforeEach(() => {
|
||||
vi.clearAllMocks();
|
||||
A2AClientManager.resetInstanceForTesting();
|
||||
manager = A2AClientManager.getInstance();
|
||||
manager.clearCache();
|
||||
|
||||
// Re-create the instances as plain objects that can be spied on
|
||||
const factoryInstance = {
|
||||
|
||||
@@ -72,10 +72,19 @@ export class A2AClientManager {
|
||||
return A2AClientManager.instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets the singleton instance. Only for testing purposes.
|
||||
* @internal
|
||||
*/
|
||||
static resetInstanceForTesting() {
|
||||
// @ts-expect-error - Resetting singleton for testing
|
||||
A2AClientManager.instance = undefined;
|
||||
}
|
||||
|
||||
/**
|
||||
* Loads an agent by fetching its AgentCard and caches the client.
|
||||
* @param name The name to assign to the agent.
|
||||
* @param agentCardUrl {string} The full URL to the agent's card.
|
||||
* @param agentCardUrl The full URL to the agent's card.
|
||||
* @param authHandler Optional authentication handler to use for this agent.
|
||||
* @returns The loaded AgentCard.
|
||||
*/
|
||||
@@ -185,7 +194,7 @@ export class A2AClientManager {
|
||||
try {
|
||||
yield* client.sendMessageStream(messageParams, {
|
||||
signal: options?.signal,
|
||||
}) as AsyncIterable<SendMessageResult>;
|
||||
});
|
||||
} catch (error: unknown) {
|
||||
const prefix = `[A2AClientManager] sendMessageStream Error [${agentName}]`;
|
||||
if (error instanceof Error) {
|
||||
|
||||
Reference in New Issue
Block a user