(body: RawJSONLines)
| 81 | * itself: injected messages always start with a well-known XML tag. |
| 82 | */ |
| 83 | export function isExternalUserMessage(body: RawJSONLines): body is Extract<RawJSONLines, { type: 'user' }> { |
| 84 | if (body.type !== 'user') return false |
| 85 | const text = extractRawUserTextContent(body.message.content) |
| 86 | if (text === null) return false |
| 87 | if (body.isSidechain === true) return false |
| 88 | if (body.isMeta === true) return false |
| 89 | |
| 90 | const trimmed = text.trimStart() |
| 91 | for (const prefix of SYSTEM_INJECTION_PREFIXES) { |
| 92 | if (trimmed.startsWith(prefix)) return false |
| 93 | } |
| 94 | return true |
| 95 | } |
| 96 | |
| 97 | /** |
| 98 | * Dedup filter for messages arriving on the realtime socket and via reconnect |
no test coverage detected