mirror of
https://github.com/aaif-goose/goose.git
synced 2026-07-03 14:10:03 +02:00
fix(mcp-apps): update ui/message to use ContentBlock[] for content (#6546)
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
This commit is contained in:
@@ -128,12 +128,22 @@ export default function McpAppRenderer({
|
||||
if (!append) {
|
||||
throw new Error('Message handler not available in this context');
|
||||
}
|
||||
append(content.text);
|
||||
|
||||
if (!Array.isArray(content)) {
|
||||
throw new Error('Invalid message format: content must be an array of ContentBlock');
|
||||
}
|
||||
|
||||
// Extract first text block from content, ignoring other block types
|
||||
const textContent = content.find((block) => block.type === 'text');
|
||||
if (!textContent) {
|
||||
throw new Error('Invalid message format: content must contain a text block');
|
||||
}
|
||||
|
||||
// MCP Apps can send other content block types, but we only append text blocks for now
|
||||
|
||||
append(textContent.text);
|
||||
window.dispatchEvent(new CustomEvent('scroll-chat-to-bottom'));
|
||||
return {
|
||||
status: 'success',
|
||||
message: 'Message appended successfully',
|
||||
} satisfies McpMethodResponse['ui/message'];
|
||||
return {} satisfies McpMethodResponse['ui/message'];
|
||||
}
|
||||
|
||||
case 'tools/call': {
|
||||
|
||||
@@ -1,8 +1,16 @@
|
||||
export type { CspMetadata, CallToolResponse as ToolResult } from '../../api/types.gen';
|
||||
|
||||
export type ContentBlock =
|
||||
| { type: 'text'; text: string }
|
||||
| { type: 'image'; data: string; mimeType: string }
|
||||
| {
|
||||
type: 'resource';
|
||||
resource: { uri: string; mimeType?: string; text?: string; blob?: string };
|
||||
};
|
||||
|
||||
export type McpMethodParams = {
|
||||
'ui/open-link': { url: string };
|
||||
'ui/message': { content: { type: string; text: string } };
|
||||
'ui/message': { role: 'user'; content: ContentBlock[] };
|
||||
'tools/call': { name: string; arguments?: Record<string, unknown> };
|
||||
'resources/read': { uri: string };
|
||||
'notifications/message': { level?: string; logger?: string; data: unknown };
|
||||
@@ -11,7 +19,7 @@ export type McpMethodParams = {
|
||||
|
||||
export type McpMethodResponse = {
|
||||
'ui/open-link': { status: string; message: string };
|
||||
'ui/message': { status: string; message: string };
|
||||
'ui/message': Record<string, never>;
|
||||
'tools/call': {
|
||||
content: unknown[];
|
||||
isError: boolean;
|
||||
|
||||
Reference in New Issue
Block a user