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