refactor: address review follow-ups for local protocol

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