char-fork/llama.cpp

git clone https://git.t4t.associates/char-fork/llama.cpp

Aleksander Grygierui: Improve Chat Messages rendering performance (#28460)0afb805b1

char/aliceai-t5-moe
744 B28 linesraw
1export function parseExecShellCommandError(
2	toolResultString: string | undefined
3): string | undefined {
4	if (!toolResultString) return undefined;
5
6	// Exec results are usually large plain-text stdout; only a JSON object
7	// root can carry an error field, so skip the parse otherwise
8	const trimmed = toolResultString.trimStart();
9
10	if (trimmed[0] !== '{') return undefined;
11
12	try {
13		const parsed: unknown = JSON.parse(trimmed);
14
15		if (
16			parsed &&
17			typeof parsed === 'object' &&
18			!Array.isArray(parsed) &&
19			typeof (parsed as Record<string, unknown>).error === 'string'
20		) {
21			return (parsed as { error: string }).error;
22		}
23	} catch {
24		// Plain-text result = stdout/stderr, no structured error to surface.
25	}
26
27	return undefined;
28}