MCPcopy Create free account
hub / github.com/Noumena-Network/code / extractConversationText

Function extractConversationText

src/utils/sessionTitle.ts:35–56  ·  view source on GitHub ↗
(messages: Message[])

Source from the content-addressed store, hash-verified

33 * recent context wins when the conversation is long.
34 */
35export function extractConversationText(messages: Message[]): string {
36 const parts: string[] = []
37 for (const msg of messages) {
38 if (msg.type !== 'user' && msg.type !== 'assistant') continue
39 if ('isMeta' in msg && msg.isMeta) continue
40 if ('origin' in msg && msg.origin && msg.origin.kind !== 'human') continue
41 const content = msg.message.content
42 if (typeof content === 'string') {
43 parts.push(content)
44 } else if (Array.isArray(content)) {
45 for (const block of content) {
46 if ('type' in block && block.type === 'text' && 'text' in block) {
47 parts.push(block.text as string)
48 }
49 }
50 }
51 }
52 const text = parts.join('\n')
53 return text.length > MAX_CONVERSATION_TEXT
54 ? text.slice(-MAX_CONVERSATION_TEXT)
55 : text
56}
57
58const SESSION_TITLE_PROMPT = `Generate a concise, sentence-case title (3-7 words) that captures the main topic or goal of this coding session. The title should be clear enough that the user recognizes the session in a list. Use sentence case: capitalize only the first word and proper nouns.
59

Callers 2

onUserMessageFunction · 0.85
generateSessionNameFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected