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
const content = [
{ 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);
await expect(session.send({ update: { title: 'test' } })).rejects.toThrow(
'only supports message sends',
);
const result = await session.send({ update: { title: 'test' } });
expect(result.streamId).toBeNull();
});
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;
if (!message) {
throw new Error(
'LegacyAgentSession.send() only supports message sends for the moment.',
);
return { streamId: null };
}
if (this._activeStreamId) {