🚦 feat: Simplify MCP UI integration and add unit tests (#9418)

This commit is contained in:
Samuel Path 2025-09-03 08:21:12 +02:00 committed by GitHub
parent f9b12517b0
commit 6d791e3e12
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 953 additions and 20 deletions

View file

@ -111,7 +111,7 @@ export function formatToolContent(
const formattedContent: t.FormattedContent[] = [];
const imageUrls: t.FormattedContent[] = [];
let currentTextBlock = '';
let uiResources: t.UIResource[] = [];
const uiResources: t.UIResource[] = [];
type ContentHandler = undefined | ((item: t.ToolContentPart) => void);
@ -183,7 +183,14 @@ export function formatToolContent(
}
if (uiResources.length) {
formattedContent.push({ type: 'text', metadata: 'ui_resources', text: btoa(JSON.stringify(uiResources))});
formattedContent.push({
type: 'text',
metadata: {
type: 'ui_resources',
data: uiResources,
},
text: '',
});
}
const artifacts = imageUrls.length ? { content: imageUrls } : undefined;