MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / formatToolOutput

Function formatToolOutput

cli/src/utils/codebuff-client.ts:183–213  ·  view source on GitHub ↗
(output: unknown)

Source from the content-addressed store, hash-verified

181}
182
183export function formatToolOutput(output: unknown): string {
184 if (!output) return ''
185
186 if (Array.isArray(output)) {
187 return output
188 .map((item) => {
189 if (item.type === 'json') {
190 // Handle errorMessage in the value object
191 if (
192 item.value &&
193 typeof item.value === 'object' &&
194 'errorMessage' in item.value
195 ) {
196 return String(item.value.errorMessage)
197 }
198 return toYaml(item.value)
199 }
200 if (item.type === 'text') {
201 return item.text || ''
202 }
203 return String(item)
204 })
205 .join('\n')
206 }
207
208 if (typeof output === 'string') {
209 return output
210 }
211
212 return toYaml(output)
213}

Callers 2

Calls 1

toYamlFunction · 0.85

Tested by

no test coverage detected