* Extract the content from the last tag in a string. * The CLI wraps raw user text in that tag; if no tag is found, returns the * original content.
(content: string)
| 52 | * original content. |
| 53 | */ |
| 54 | function extractLastUserMessageContent(content: string): string { |
| 55 | const regex = /<user_message>([\s\S]*?)<\/user_message>/gi |
| 56 | const matches = [...content.matchAll(regex)] |
| 57 | if (matches.length > 0) { |
| 58 | const lastMatch = matches[matches.length - 1] |
| 59 | return lastMatch[1].trim() |
| 60 | } |
| 61 | return content |
| 62 | } |
| 63 | |
| 64 | /** |
| 65 | * Gravity only wants the last user turn plus the last preceding assistant |
no outgoing calls
no test coverage detected