( messages: UserMessage[], )
| 3487 | } |
| 3488 | |
| 3489 | export function wrapMessagesInSystemReminder( |
| 3490 | messages: UserMessage[], |
| 3491 | ): UserMessage[] { |
| 3492 | return messages.map(msg => { |
| 3493 | if (typeof msg.message.content === 'string') { |
| 3494 | return { |
| 3495 | ...msg, |
| 3496 | message: { |
| 3497 | ...msg.message, |
| 3498 | content: wrapInSystemReminder(msg.message.content), |
| 3499 | }, |
| 3500 | } |
| 3501 | } else if (Array.isArray(msg.message.content)) { |
| 3502 | // For array content, wrap text blocks in system-reminder |
| 3503 | const wrappedContent = msg.message.content.map(block => { |
| 3504 | if (block.type === 'text') { |
| 3505 | return { |
| 3506 | ...block, |
| 3507 | text: wrapInSystemReminder(block.text), |
| 3508 | } |
| 3509 | } |
| 3510 | return block |
| 3511 | }) |
| 3512 | return { |
| 3513 | ...msg, |
| 3514 | message: { |
| 3515 | ...msg.message, |
| 3516 | content: wrappedContent, |
| 3517 | }, |
| 3518 | } |
| 3519 | } |
| 3520 | return msg |
| 3521 | }) |
| 3522 | } |
| 3523 | |
| 3524 | function getPlanModeInstructions(attachment: { |
| 3525 | reminderType: 'full' | 'sparse' |
no test coverage detected