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

Function flattenBlockText

tools/claw-launcher-ui/server.mjs:431–450  ·  view source on GitHub ↗
(content)

Source from the content-addressed store, hash-verified

429}
430
431function flattenBlockText(content) {
432 if (typeof content === 'string') {
433 return content
434 }
435 if (!Array.isArray(content)) {
436 return ''
437 }
438 return content
439 .map(block => {
440 if (typeof block === 'string') {
441 return block
442 }
443 if (block?.type === 'text' && typeof block.text === 'string') {
444 return block.text
445 }
446 return JSON.stringify(block)
447 })
448 .join('\n')
449 .trim()
450}
451
452function trimContextText(value, max = contextEntryCharLimit) {
453 const text = String(value || '').trim()

Callers 2

readSessionStateFunction · 0.85
runConnectionDiagnosticsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected