( messages: UserMessage[], )
| 3199 | } |
| 3200 | |
| 3201 | export function wrapMessagesInSystemReminder( |
| 3202 | messages: UserMessage[], |
| 3203 | ): UserMessage[] { |
| 3204 | return messages.map(msg => { |
| 3205 | if (typeof msg.message.content === 'string') { |
| 3206 | return { |
| 3207 | ...msg, |
| 3208 | message: { |
| 3209 | ...msg.message, |
| 3210 | content: wrapInSystemReminder(msg.message.content), |
| 3211 | }, |
| 3212 | } |
| 3213 | } else if (Array.isArray(msg.message.content)) { |
| 3214 | // For array content, wrap text blocks in system-reminder |
| 3215 | const wrappedContent = msg.message.content.map(block => { |
| 3216 | if (block.type === 'text') { |
| 3217 | return { |
| 3218 | ...block, |
| 3219 | text: wrapInSystemReminder(block.text), |
| 3220 | } |
| 3221 | } |
| 3222 | return block |
| 3223 | }) |
| 3224 | return { |
| 3225 | ...msg, |
| 3226 | message: { |
| 3227 | ...msg.message, |
| 3228 | content: wrappedContent, |
| 3229 | }, |
| 3230 | } |
| 3231 | } |
| 3232 | return msg |
| 3233 | }) |
| 3234 | } |
| 3235 | |
| 3236 | function getPlanModeInstructions(attachment: { |
| 3237 | reminderType: 'full' | 'sparse' |
no test coverage detected