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

Function extractRawUserTextContent

cli/src/api/apiSession.ts:51–71  ·  view source on GitHub ↗
(content: unknown)

Source from the content-addressed store, hash-verified

49]
50
51function extractRawUserTextContent(content: unknown): string | null {
52 if (typeof content === 'string') {
53 return content
54 }
55
56 if (!Array.isArray(content)) {
57 return null
58 }
59
60 const parts = content
61 .map((block) => {
62 if (!block || typeof block !== 'object' || Array.isArray(block)) return null
63 const record = block as Record<string, unknown>
64 return record.type === 'text' && typeof record.text === 'string'
65 ? record.text
66 : null
67 })
68 .filter((text): text is string => text !== null)
69
70 return parts.length > 0 ? parts.join('\n') : null
71}
72
73/**
74 * Returns true if a JSONL message should be classified as a user-role message

Callers 2

isExternalUserMessageFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected