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

Function _message_text

src/command_system/copy_command.py:103–121  ·  view source on GitHub ↗

Assistant text joined with '\\n\\n' (TS extractTextContent(content, '\\n\\n')).

(msg: Any)

Source from the content-addressed store, hash-verified

101
102
103def _message_text(msg: Any) -> str:
104 """Assistant text joined with '\\n\\n' (TS extractTextContent(content, '\\n\\n'))."""
105 from src.utils.export_renderer import extract_message_content
106
107 content = extract_message_content(msg)
108 if isinstance(content, str):
109 return content.strip()
110 if isinstance(content, list):
111 parts: list[str] = []
112 for block in content:
113 if isinstance(block, Mapping):
114 if block.get("type") in (None, "text") and block.get("text"):
115 parts.append(str(block["text"]))
116 else:
117 text = getattr(block, "text", None)
118 if text and getattr(block, "type", "text") in (None, "text"):
119 parts.append(str(text))
120 return "\n\n".join(parts).strip()
121 return ""
122
123
124def collect_recent_assistant_texts(messages: Any) -> list[str]:

Callers 1

Calls 4

extract_message_contentFunction · 0.90
joinMethod · 0.80
getMethod · 0.45
appendMethod · 0.45

Tested by

no test coverage detected