| 37 | } |
| 38 | |
| 39 | function formatRecentMessages(messages: Message[]): string { |
| 40 | return messages |
| 41 | .filter(m => m.type === 'user' || m.type === 'assistant') |
| 42 | .map(m => { |
| 43 | const role = m.type === 'user' ? 'User' : 'Assistant' |
| 44 | const content = m.message.content |
| 45 | if (typeof content === 'string') |
| 46 | return `${role}: ${content.slice(0, 500)}` |
| 47 | const text = content |
| 48 | .filter( |
| 49 | (b): b is Extract<typeof b, { type: 'text' }> => b.type === 'text', |
| 50 | ) |
| 51 | .map(b => b.text) |
| 52 | .join('\n') |
| 53 | return `${role}: ${text.slice(0, 500)}` |
| 54 | }) |
| 55 | .join('\n\n') |
| 56 | } |
| 57 | |
| 58 | function findProjectSkill() { |
| 59 | const skills = getInvokedSkillsForAgent(null) |