2025-12-17 12:06:38 -05:00
|
|
|
/**
|
|
|
|
|
* @license
|
|
|
|
|
* Copyright 2025 Google LLC
|
|
|
|
|
* SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import { describe, it, expect } from 'vitest';
|
|
|
|
|
import type { ToolCallConfirmationDetails } from '../tools/tools.js';
|
|
|
|
|
import { RemoteAgentInvocation } from './remote-invocation.js';
|
|
|
|
|
import type { RemoteAgentDefinition } from './types.js';
|
2026-01-04 17:11:43 -05:00
|
|
|
import { createMockMessageBus } from '../test-utils/mock-message-bus.js';
|
2025-12-17 12:06:38 -05:00
|
|
|
|
|
|
|
|
class TestableRemoteAgentInvocation extends RemoteAgentInvocation {
|
|
|
|
|
override async getConfirmationDetails(
|
|
|
|
|
abortSignal: AbortSignal,
|
|
|
|
|
): Promise<ToolCallConfirmationDetails | false> {
|
|
|
|
|
return super.getConfirmationDetails(abortSignal);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
describe('RemoteAgentInvocation', () => {
|
|
|
|
|
const mockDefinition: RemoteAgentDefinition = {
|
|
|
|
|
kind: 'remote',
|
|
|
|
|
name: 'test-remote-agent',
|
|
|
|
|
description: 'A test remote agent',
|
|
|
|
|
displayName: 'Test Remote Agent',
|
|
|
|
|
agentCardUrl: 'https://example.com/agent-card',
|
|
|
|
|
inputConfig: {
|
|
|
|
|
inputs: {},
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2026-01-04 17:11:43 -05:00
|
|
|
const mockMessageBus = createMockMessageBus();
|
|
|
|
|
|
2025-12-17 12:06:38 -05:00
|
|
|
it('should be instantiated with correct params', () => {
|
2026-01-04 17:11:43 -05:00
|
|
|
const invocation = new RemoteAgentInvocation(
|
|
|
|
|
mockDefinition,
|
|
|
|
|
{},
|
|
|
|
|
mockMessageBus,
|
|
|
|
|
);
|
2025-12-17 12:06:38 -05:00
|
|
|
expect(invocation).toBeDefined();
|
|
|
|
|
expect(invocation.getDescription()).toBe(
|
|
|
|
|
'Calling remote agent Test Remote Agent',
|
|
|
|
|
);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
it('should return false for confirmation details (not yet implemented)', async () => {
|
2026-01-04 17:11:43 -05:00
|
|
|
const invocation = new TestableRemoteAgentInvocation(
|
|
|
|
|
mockDefinition,
|
|
|
|
|
{},
|
|
|
|
|
mockMessageBus,
|
|
|
|
|
);
|
2025-12-17 12:06:38 -05:00
|
|
|
const details = await invocation.getConfirmationDetails(
|
|
|
|
|
new AbortController().signal,
|
|
|
|
|
);
|
|
|
|
|
expect(details).toBe(false);
|
|
|
|
|
});
|
|
|
|
|
});
|