MCPcopy
hub / github.com/claude-code-best/claude-code / normalizeMessage

Function normalizeMessage

src/utils/queryHelpers.ts:112–245  ·  view source on GitHub ↗
(message: Message)

Source from the content-addressed store, hash-verified

110const toolProgressLastSentTime = new Map<string, number>()
111
112export function* normalizeMessage(message: Message): Generator<SDKMessage> {
113 switch (message.type) {
114 case 'assistant':
115 for (const _ of normalizeMessages([message])) {
116 // Skip empty messages (e.g., "(no content)") that shouldn't be output to SDK
117 if (!isNotEmptyMessage(_)) {
118 continue
119 }
120 yield {
121 type: 'assistant',
122 message: _.message,
123 parent_tool_use_id: null,
124 session_id: getSessionId(),
125 uuid: _.uuid,
126 error: _.error,
127 }
128 }
129 return
130 case 'progress': {
131 const progressData = message.data as {
132 type: string
133 message: Message
134 elapsedTimeSeconds: number
135 taskId: string
136 }
137 if (
138 progressData.type === 'agent_progress' ||
139 progressData.type === 'skill_progress'
140 ) {
141 for (const _ of normalizeMessages([progressData.message])) {
142 switch (_.type) {
143 case 'assistant':
144 // Skip empty messages (e.g., "(no content)") that shouldn't be output to SDK
145 if (!isNotEmptyMessage(_)) {
146 break
147 }
148 yield {
149 type: 'assistant',
150 message: _.message,
151 parent_tool_use_id: message.parentToolUseID as string,
152 session_id: getSessionId(),
153 uuid: _.uuid,
154 error: _.error,
155 }
156 break
157 case 'user':
158 yield {
159 type: 'user',
160 message: _.message,
161 parent_tool_use_id: message.parentToolUseID as string,
162 session_id: getSessionId(),
163 uuid: _.uuid,
164 timestamp: _.timestamp,
165 isSynthetic: _.isMeta || _.isVisibleInTranscriptOnly,
166 tool_use_result: _.mcpMeta
167 ? {
168 content: _.toolUseResult,
169 ...(_.mcpMeta as Record<string, unknown>),

Callers 1

submitMessageMethod · 0.85

Calls 10

normalizeMessagesFunction · 0.85
isNotEmptyMessageFunction · 0.85
getSessionIdFunction · 0.85
nowMethod · 0.80
nextMethod · 0.80
setMethod · 0.80
isEnvTruthyFunction · 0.70
getMethod · 0.65
keysMethod · 0.65
deleteMethod · 0.65

Tested by

no test coverage detected