mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-05-14 05:42:54 -07:00
refactor: address review follow-ups for local protocol
This commit is contained in:
@@ -187,7 +187,7 @@ describe('contentPartsToGeminiParts', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
it('throws on unknown ContentPart variants', () => {
|
||||
it('serializes unknown ContentPart variants', () => {
|
||||
// Force an unknown variant past the type system
|
||||
const content = [
|
||||
{ type: 'custom_widget', payload: 123 },
|
||||
|
||||
@@ -241,10 +241,11 @@ describe('LegacyAgentSession', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('returns null streamId for non-message payloads', async () => {
|
||||
it('throws for non-message payloads', async () => {
|
||||
const session = new LegacyAgentSession(deps);
|
||||
const result = await session.send({ update: { title: 'test' } });
|
||||
expect(result.streamId).toBeNull();
|
||||
await expect(session.send({ update: { title: 'test' } })).rejects.toThrow(
|
||||
'only supports message sends',
|
||||
);
|
||||
});
|
||||
|
||||
it('throws if send is called while a stream is active', async () => {
|
||||
|
||||
@@ -105,10 +105,12 @@ export class LegacyAgentProtocol implements AgentProtocol {
|
||||
};
|
||||
}
|
||||
|
||||
async send(payload: AgentSend): Promise<{ streamId: string | null }> {
|
||||
async send(payload: AgentSend): Promise<{ streamId: string }> {
|
||||
const message = 'message' in payload ? payload.message : undefined;
|
||||
if (!message) {
|
||||
return { streamId: null };
|
||||
throw new Error(
|
||||
'LegacyAgentSession.send() only supports message sends for the moment.',
|
||||
);
|
||||
}
|
||||
|
||||
if (this._activeStreamId) {
|
||||
|
||||
Reference in New Issue
Block a user