MCPcopy Create free account
hub / github.com/Work-Fisher/code-claw / normalizeAssistantContent

Function normalizeAssistantContent

compatible-shell/src/cli.mjs:217–248  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

215}
216
217function normalizeAssistantContent(content) {
218 if (typeof content === 'string') {
219 return [{ type: 'text', text: content }]
220 }
221
222 if (!Array.isArray(content)) {
223 return []
224 }
225
226 return content
227 .map(block => {
228 if (block?.type === 'text') {
229 return {
230 type: 'text',
231 text: typeof block.text === 'string' ? block.text : '',
232 }
233 }
234
235 if (block?.type === 'tool_use') {
236 return {
237 type: 'tool_use',
238 id: block.id || `toolu_${Date.now()}`,
239 name: block.name || 'tool',
240 input:
241 typeof block.input === 'object' && block.input !== null ? block.input : {},
242 }
243 }
244
245 return null
246 })
247 .filter(Boolean)
248}
249
250function printAssistantText(content) {
251 const text = content

Callers 1

runUserTurnFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected