MCPcopy Create free account
hub / github.com/agentforce314/clawcodex / _plain_block_lines

Function _plain_block_lines

src/utils/export_renderer.py:657–706  ·  view source on GitHub ↗
(block: dict, lines: List[str], skip_subheading: bool)

Source from the content-addressed store, hash-verified

655
656
657def _plain_block_lines(block: dict, lines: List[str], skip_subheading: bool) -> None:
658 block_type = block.get("type")
659
660 if block_type == "text":
661 text = block.get("text")
662 stripped = strip_top_level_internal_text(text) if isinstance(text, str) else ""
663 if stripped:
664 lines.append(stripped)
665 lines.append("")
666 return
667
668 if block_type == "tool_use":
669 name = block.get("name")
670 name = name if isinstance(name, str) else "unknown"
671 lines.append(f"Tool Use: {name}")
672 tool_input = block.get("input")
673 if tool_input is not None:
674 lines.append(safe_stringify(tool_input, 2))
675 lines.append("")
676 return
677
678 if block_type == "tool_result":
679 if not skip_subheading:
680 lines.append("Tool Result")
681 result_content = block.get("content")
682 if result_content is not None:
683 as_string = (
684 strip_system_reminder_blocks(result_content)
685 if isinstance(result_content, str)
686 else safe_stringify(result_content, 2)
687 )
688 if as_string:
689 lines.append(as_string)
690 if block.get("isError") or block.get("is_error"):
691 lines.append("(Error)")
692 lines.append("")
693 return
694
695 if block_type == "image":
696 lines.append("[Image attachment]")
697 lines.append("")
698 return
699
700 if block_type in ("thinking", "redacted_thinking"):
701 return
702
703 label = block_type if block_type is not None else "unknown"
704 lines.append(f"[{label} content block]")
705 lines.append(safe_stringify(block, 2))
706 lines.append("")
707
708
709def render_messages_to_plain_text(messages: Any) -> str:

Callers 1

Calls 5

safe_stringifyFunction · 0.85
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected