diff --git a/web/src/components/ToolCard/views/_results.tsx b/web/src/components/ToolCard/views/_results.tsx index 5620ae97..c2e552a6 100644 --- a/web/src/components/ToolCard/views/_results.tsx +++ b/web/src/components/ToolCard/views/_results.tsx @@ -95,6 +95,26 @@ function extractTextFromResult(result: unknown, depth: number = 0): string | nul return null } +interface CodexBashOutput { + exitCode: number | null + wallTime: string | null + output: string +} + +function parseCodexBashOutput(text: string): CodexBashOutput | null { + const exitMatch = text.match(/^Exit code:\s*(\d+)/m) + const wallMatch = text.match(/^Wall time:\s*(.+)$/m) + const outputMatch = text.match(/^Output:\n([\s\S]*)$/m) + + if (!exitMatch && !wallMatch && !outputMatch) return null + + return { + exitCode: exitMatch ? parseInt(exitMatch[1], 10) : null, + wallTime: wallMatch ? wallMatch[1].trim() : null, + output: outputMatch ? outputMatch[1] : text + } +} + function looksLikeHtml(text: string): boolean { const trimmed = text.trimStart() return trimmed.startsWith(' { return