MCPcopy Create free account
hub / github.com/AnukarOP/claude-code-leaked / extractMessageText

Function extractMessageText

source code/utils/agenticSessionSearch.ts:59–83  ·  view source on GitHub ↗

* Extracts searchable text content from a message.

(message: SerializedMessage)

Source from the content-addressed store, hash-verified

57 * Extracts searchable text content from a message.
58 */
59function extractMessageText(message: SerializedMessage): string {
60 if (message.type !== 'user' && message.type !== 'assistant') {
61 return ''
62 }
63
64 const content = 'message' in message ? message.message?.content : undefined
65 if (!content) return ''
66
67 if (typeof content === 'string') {
68 return content
69 }
70
71 if (Array.isArray(content)) {
72 return content
73 .map(block => {
74 if (typeof block === 'string') return block
75 if ('text' in block && typeof block.text === 'string') return block.text
76 return ''
77 })
78 .filter(Boolean)
79 .join(' ')
80 }
81
82 return ''
83}
84
85/**
86 * Extracts a truncated transcript from session messages.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected