From 00fa33089f1b39700ff9bc4afd6e134b80ce5c88 Mon Sep 17 00:00:00 2001 From: retz8 Date: Sat, 24 Oct 2026 14:20:18 +0900 Subject: [PATCH] fix(samples): put the MIME type in part metadata in the Lit and React clients The Lit shell's A2UIClient and the React shell's A2A middleware set `mimeType` on the data part itself, beside `kind` and `data`, and cast the object to Part to get past the type. An A2A 0.3 DataPart has no such field, and the extension specs put the MIME type in the part's metadata. The Python a2a-sdk drops the unknown field when it parses the message, so is_a2ui_part returns False for every client event these shells send. Move it to `metadata.mimeType`, as the Angular client and the Lit shell's own middleware do, and drop the casts so the compiler checks the part's shape. The Lit client's useStreaming part takes the same change. --- samples/client/lit/shell/client.ts | 12 ++++++------ samples/client/react/shell/middleware/a2a.ts | 6 +++--- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/samples/client/lit/shell/client.ts b/samples/client/lit/shell/client.ts index 78168103e2..c2c70e1860 100644 --- a/samples/client/lit/shell/client.ts +++ b/samples/client/lit/shell/client.ts @@ -68,8 +68,8 @@ export class A2UIClient { { kind: 'data', data: parsed as unknown as Record, - mimeType: A2UI_MIME_TYPE, - } as Part, + metadata: {mimeType: A2UI_MIME_TYPE}, + }, ]; } else { parts = [{kind: 'text', text: message}]; @@ -82,16 +82,16 @@ export class A2UIClient { { kind: 'data', data: message as unknown as Record, - mimeType: A2UI_MIME_TYPE, - } as Part, + metadata: {mimeType: A2UI_MIME_TYPE}, + }, ]; } parts.push({ kind: 'data', data: {useStreaming: false}, - mimeType: 'application/json', - } as Part); + metadata: {mimeType: 'application/json'}, + }); const response = await client.sendMessage({ message: { diff --git a/samples/client/react/shell/middleware/a2a.ts b/samples/client/react/shell/middleware/a2a.ts index a1b8da814a..a5f0ef8274 100644 --- a/samples/client/react/shell/middleware/a2a.ts +++ b/samples/client/react/shell/middleware/a2a.ts @@ -17,7 +17,7 @@ import {IncomingMessage, ServerResponse} from 'http'; import {Plugin, ViteDevServer} from 'vite'; import {A2AClient} from '@a2a-js/sdk/client'; -import {MessageSendParams, Part, SendMessageSuccessResponse, Task} from '@a2a-js/sdk'; +import {MessageSendParams, SendMessageSuccessResponse, Task} from '@a2a-js/sdk'; import * as crypto from 'crypto'; const A2UI_MIME_TYPE = 'application/a2ui+json'; @@ -101,8 +101,8 @@ export const plugin = (): Plugin => { { kind: 'data', data: clientEvent, - mimeType: A2UI_MIME_TYPE, - } as Part, + metadata: {mimeType: A2UI_MIME_TYPE}, + }, ], kind: 'message', },