converse-mcp-server 2.5.2 → 2.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "converse-mcp-server",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "Converse MCP Server - Converse with other LLMs with chat and consensus tools",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -203,19 +203,22 @@ function mapFinishReason(finishReason) {
203
203
  }
204
204
 
205
205
  /**
206
- * Convert messages from Converse internal format to Gemini CLI SDK format
206
+ * Convert messages from Converse internal format to AI SDK v5 ModelMessage format
207
207
  *
208
208
  * Converse format (used by other providers like Anthropic):
209
209
  * - Images: { type: 'image', source: { type: 'base64', media_type: '...', data: '...' } }
210
210
  *
211
- * Gemini CLI SDK format (from SDK guide):
212
- * - Images: { type: 'image', data: '...' } (base64 string)
211
+ * AI SDK v5 ModelMessage format (required by generateText/streamText):
212
+ * - Images: { type: 'image', image: '...' } (base64 string, Buffer, or URL)
213
213
  * - Text: { type: 'text', text: '...' }
214
214
  *
215
+ * Note: The AI SDK validates ModelMessage format before passing to providers.
216
+ * We must use 'image' property (not 'data') for the AI SDK to accept the message.
217
+ *
215
218
  * @param {Array} messages - Messages in Converse internal format
216
- * @returns {Array} Messages in Gemini CLI SDK format
219
+ * @returns {Array} Messages in AI SDK v5 ModelMessage format
217
220
  */
218
- function convertToGeminiCliMessages(messages) {
221
+ function convertToModelMessages(messages) {
219
222
  return messages.map((message) => {
220
223
  // If content is a string, no conversion needed
221
224
  if (typeof message.content === 'string') {
@@ -230,20 +233,20 @@ function convertToGeminiCliMessages(messages) {
230
233
  return part;
231
234
  }
232
235
 
233
- // Convert image from Converse format to Gemini CLI SDK format
236
+ // Convert image from Converse format to AI SDK v5 ModelMessage format
234
237
  if (part.type === 'image' && part.source) {
235
238
  return {
236
239
  type: 'image',
237
- data: part.source.data, // Extract base64 data (use 'data' not 'image')
240
+ image: part.source.data, // AI SDK v5 expects 'image' property (not 'data')
238
241
  };
239
242
  }
240
243
 
241
- // If already in Gemini CLI format, return as-is
242
- if (part.type === 'image' && part.data) {
244
+ // If already in AI SDK v5 format, return as-is
245
+ if (part.type === 'image' && part.image) {
243
246
  return part;
244
247
  }
245
248
 
246
- // Handle file parts (future-proofing)
249
+ // Handle file parts (already in correct format)
247
250
  if (part.type === 'file' && part.data) {
248
251
  return part;
249
252
  }
@@ -326,8 +329,8 @@ export const geminiCliProvider = {
326
329
  // Create model instance with SDK model name
327
330
  const modelInstance = gemini(sdkModelName);
328
331
 
329
- // Convert messages from Converse format to Gemini CLI SDK format
330
- const convertedMessages = convertToGeminiCliMessages(messages);
332
+ // Convert messages from Converse format to AI SDK v5 ModelMessage format
333
+ const convertedMessages = convertToModelMessages(messages);
331
334
 
332
335
  // Build AI SDK options
333
336
  const aiOptions = {