mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-12 04:17:15 -07:00
fixes
This commit is contained in:
@@ -200,40 +200,6 @@ describe('LegacyAgentSession', () => {
|
||||
await collectEvents(session, { streamId: streamId ?? undefined });
|
||||
});
|
||||
|
||||
it('accepts legacy message-array sends without displayContent', async () => {
|
||||
const sendMock = deps.client.sendMessageStream as ReturnType<
|
||||
typeof vi.fn
|
||||
>;
|
||||
sendMock.mockReturnValue(
|
||||
makeStream([
|
||||
{
|
||||
type: GeminiEventType.Finished,
|
||||
value: { reason: FinishReason.STOP, usageMetadata: undefined },
|
||||
},
|
||||
]),
|
||||
);
|
||||
|
||||
const session = new LegacyAgentSession(deps);
|
||||
const { streamId } = await session.send({
|
||||
message: [{ type: 'text', text: 'hi' }],
|
||||
});
|
||||
|
||||
const userMessage = session.events.find(
|
||||
(e): e is AgentEvent<'message'> =>
|
||||
e.type === 'message' && e.role === 'user' && e.streamId === streamId,
|
||||
);
|
||||
expect(userMessage?.content).toEqual([{ type: 'text', text: 'hi' }]);
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
expect(sendMock).toHaveBeenCalledWith(
|
||||
[{ text: 'hi' }],
|
||||
expect.any(AbortSignal),
|
||||
'test-prompt',
|
||||
undefined,
|
||||
false,
|
||||
undefined,
|
||||
);
|
||||
});
|
||||
|
||||
it('returns streamId before emitting agent_start', async () => {
|
||||
const sendMock = deps.client.sendMessageStream as ReturnType<
|
||||
typeof vi.fn
|
||||
|
||||
@@ -93,9 +93,6 @@ class LegacyAgentProtocol implements AgentProtocol {
|
||||
'LegacyAgentSession.send() only supports message sends for the moment.',
|
||||
);
|
||||
}
|
||||
const normalizedMessage = Array.isArray(message)
|
||||
? { content: message, displayContent: undefined }
|
||||
: message;
|
||||
|
||||
if (this._activeStreamId) {
|
||||
// TODO: Interactive may eventually allow selected in-stream sends such as
|
||||
@@ -108,16 +105,16 @@ class LegacyAgentProtocol implements AgentProtocol {
|
||||
|
||||
this._beginNewStream();
|
||||
const streamId = this._translationState.streamId;
|
||||
const parts = contentPartsToGeminiParts(normalizedMessage.content);
|
||||
const parts = contentPartsToGeminiParts(message.content);
|
||||
const userMessage = this._makeUserMessageEvent(
|
||||
normalizedMessage.content,
|
||||
normalizedMessage.displayContent,
|
||||
message.content,
|
||||
message.displayContent,
|
||||
payload._meta,
|
||||
);
|
||||
|
||||
this._emit([userMessage]);
|
||||
|
||||
this._scheduleRunLoop(parts, normalizedMessage.displayContent);
|
||||
this._scheduleRunLoop(parts, message.displayContent);
|
||||
|
||||
return { streamId };
|
||||
}
|
||||
|
||||
@@ -46,12 +46,10 @@ type RequireExactlyOne<T> = {
|
||||
}[keyof T];
|
||||
|
||||
interface AgentSendPayloads {
|
||||
message:
|
||||
| ContentPart[]
|
||||
| {
|
||||
content: ContentPart[];
|
||||
displayContent?: string;
|
||||
};
|
||||
message: {
|
||||
content: ContentPart[];
|
||||
displayContent?: string;
|
||||
};
|
||||
elicitations: ElicitationResponse[];
|
||||
update: { title?: string; model?: string; config?: Record<string, unknown> };
|
||||
action: { type: string; data: unknown };
|
||||
|
||||
Reference in New Issue
Block a user