feat(webchat): support image attachments

This commit is contained in:
William Valentin
2026-02-13 15:03:48 -08:00
parent 955b9e28e0
commit cc54b3a10c
7 changed files with 707 additions and 31 deletions
+22 -1
View File
@@ -323,7 +323,28 @@ describe('agent handlers', () => {
expect(sent).toHaveLength(1);
});
it('agent.send requires message', async () => {
it('agent.send accepts attachment-only requests', async () => {
const req: GatewayRequest = {
id: 12,
method: 'agent.send',
params: {
connectionId: 'conn-1',
attachments: [{ mimeType: 'image/png', data: 'iVBOR...' }],
},
};
const sent: OutboundMessage[] = [];
const send = vi.fn((msg: OutboundMessage) => sent.push(msg));
await handlers['agent.send'](req, send);
expect(mockAgent.process).toHaveBeenCalledWith('', [
{ mimeType: 'image/png', data: 'iVBOR...', url: undefined, filename: undefined },
]);
expect(sent).toHaveLength(1);
expect((sent[0] as GatewayEvent).event).toBe('done');
});
it('agent.send requires message or attachments', async () => {
const req: GatewayRequest = { id: 2, method: 'agent.send', params: { connectionId: 'conn-1' } };
const send = vi.fn();
const result = await handlers['agent.send'](req, send) as GatewayError;