MCPcopy Index your code
hub / github.com/ChatLab/ChatLab / formatObjectWithMessages

Function formatObjectWithMessages

packages/mcp-server/src/format.ts:188–206  ·  view source on GitHub ↗
(obj: Record<string, unknown>, msgs: FormattableMessage[])

Source from the content-addressed store, hash-verified

186}
187
188function formatObjectWithMessages(obj: Record<string, unknown>, msgs: FormattableMessage[]): string {
189 const lines: string[] = []
190
191 for (const [key, value] of Object.entries(obj)) {
192 if (key === 'messages') continue
193 if (value === undefined || value === null) continue
194 if (typeof value === 'object' && !Array.isArray(value)) continue
195 if (Array.isArray(value)) continue
196 lines.push(`${key}: ${value}`)
197 }
198
199 const formatted = formatMessagesCompact(msgs)
200 if (formatted) {
201 if (lines.length > 0) lines.push('')
202 lines.push(formatted)
203 }
204
205 return lines.join('\n')
206}
207
208function formatArrayResult(obj: Record<string, unknown>): string {
209 const lines: string[] = []

Callers 1

formatToolResultAsTextFunction · 0.85

Calls 1

formatMessagesCompactFunction · 0.85

Tested by

no test coverage detected