| 268 | |
| 269 | // Helper function to create a summary of multiple messages |
| 270 | export function createMessagesSummary(messages: any[]): string { |
| 271 | if (messages.length === 0) { |
| 272 | return 'No messages found.' |
| 273 | } |
| 274 | |
| 275 | let summary = `Found ${messages.length} messages:\n\n` |
| 276 | |
| 277 | messages.forEach((msg, index) => { |
| 278 | summary += `${index + 1}. Subject: ${msg.subject}\n` |
| 279 | summary += ` From: ${msg.from}\n` |
| 280 | summary += ` To: ${msg.to}\n` |
| 281 | summary += ` Date: ${msg.date}\n` |
| 282 | summary += ` ID: ${msg.id}\n` |
| 283 | summary += ` Thread ID: ${msg.threadId}\n` |
| 284 | summary += ` Preview: ${msg.snippet}\n\n` |
| 285 | }) |
| 286 | |
| 287 | summary += `To read full content of a specific message, use the gmail_read tool with messageId: ${messages.map((m) => m.id).join(', ')}` |
| 288 | |
| 289 | return summary |
| 290 | } |
| 291 | |
| 292 | /** |
| 293 | * Generate a unique MIME boundary string |