refactor: address review comments for local protocol

This commit is contained in:
Adam Weidman
2026-05-07 14:09:21 -04:00
parent 34d41c3e8d
commit 71fef59bcb
3 changed files with 6 additions and 9 deletions
@@ -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) {