1235
*/
1236
handleClientToolCallComplete(toolCallId: string, result: ToolCallResult) {
1238
>
if (!result.success && this._cancelMcpAuthenticationForToolCall(toolCallId)) {
1239
this._activeToolCalls.delete(toolCallId);
1240
return;
1241
}
1242
const textContent = result.content
1244
>
.map(c => c.text)
1245
>
.join('\n') ?? '';
1246
>
1247
>
const binaryResults = result.content
1248
>
?.filter(c => c.type === ToolResultContentType.EmbeddedResource)
1249
>
.map(c => ({ data: c.data, mimeType: c.contentType, type: (/^image(\/|$)/.test(c.contentType) ? 'image' : 'resource') as 'image' | 'resource' }));
1250
>
const textResultForLlm = textContent.trim() ? textContent : getEmptyToolResultText(binaryResults);
1251
>
1252
>
if (result.success) {
1253
this._pendingClientToolCalls.respondOrBuffer(toolCallId, {
1254
textResultForLlm,