mirror of
https://github.com/ggml-org/llama.cpp.git
synced 2026-09-30 09:57:38 -05:00
23 lines
525 B
TypeScript
23 lines
525 B
TypeScript
export function parseExecShellCommandError(
|
|
toolResultString: string | undefined
|
|
): string | undefined {
|
|
if (!toolResultString) return undefined;
|
|
|
|
try {
|
|
const parsed: unknown = JSON.parse(toolResultString);
|
|
|
|
if (
|
|
parsed &&
|
|
typeof parsed === 'object' &&
|
|
!Array.isArray(parsed) &&
|
|
typeof (parsed as Record<string, unknown>).error === 'string'
|
|
) {
|
|
return (parsed as { error: string }).error;
|
|
}
|
|
} catch {
|
|
// Plain-text result = stdout/stderr, no structured error to surface.
|
|
}
|
|
|
|
return undefined;
|
|
}
|