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 +1 -1
- package/src/providers/gemini-cli.js +15 -12
package/package.json
CHANGED
|
@@ -203,19 +203,22 @@ function mapFinishReason(finishReason) {
|
|
|
203
203
|
}
|
|
204
204
|
|
|
205
205
|
/**
|
|
206
|
-
* Convert messages from Converse internal format to
|
|
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
|
-
*
|
|
212
|
-
* - Images: { type: 'image',
|
|
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
|
|
219
|
+
* @returns {Array} Messages in AI SDK v5 ModelMessage format
|
|
217
220
|
*/
|
|
218
|
-
function
|
|
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
|
|
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
|
-
|
|
240
|
+
image: part.source.data, // AI SDK v5 expects 'image' property (not 'data')
|
|
238
241
|
};
|
|
239
242
|
}
|
|
240
243
|
|
|
241
|
-
// If already in
|
|
242
|
-
if (part.type === 'image' && part.
|
|
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 (
|
|
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
|
|
330
|
-
const convertedMessages =
|
|
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 = {
|