MCPcopy Create free account
hub / github.com/tiann/hapi / isExternalUserMessage

Function isExternalUserMessage

cli/src/api/apiSession.ts:83–95  ·  view source on GitHub ↗
(body: RawJSONLines)

Source from the content-addressed store, hash-verified

81 * itself: injected messages always start with a well-known XML tag.
82 */
83export 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

Callers 2

apiSession.test.tsFile · 0.90

Calls 1

Tested by

no test coverage detected