( messages: UserMessage[], )
| 3099 | } |
| 3100 | |
| 3101 | export function wrapMessagesInSystemReminder( |
| 3102 | messages: UserMessage[], |
| 3103 | ): UserMessage[] { |
| 3104 | return messages.map(msg => { |
| 3105 | if (typeof msg.message.content === 'string') { |
| 3106 | return { |
| 3107 | ...msg, |
| 3108 | message: { |
| 3109 | ...msg.message, |
| 3110 | content: wrapInSystemReminder(msg.message.content), |
| 3111 | }, |
| 3112 | } |
| 3113 | } else if (Array.isArray(msg.message.content)) { |
| 3114 | // For array content, wrap text blocks in system-reminder |
| 3115 | const wrappedContent = msg.message.content.map(block => { |
| 3116 | if (block.type === 'text') { |
| 3117 | return { |
| 3118 | ...block, |
| 3119 | text: wrapInSystemReminder(block.text), |
| 3120 | } |
| 3121 | } |
| 3122 | return block |
| 3123 | }) |
| 3124 | return { |
| 3125 | ...msg, |
| 3126 | message: { |
| 3127 | ...msg.message, |
| 3128 | content: wrappedContent, |
| 3129 | }, |
| 3130 | } |
| 3131 | } |
| 3132 | return msg |
| 3133 | }) |
| 3134 | } |
| 3135 | |
| 3136 | function getPlanModeInstructions(attachment: { |
| 3137 | reminderType: 'full' | 'sparse' |
no test coverage detected