fix: update tool installation checks and refactor stdout JSON parsing in AI modules

This commit is contained in:
ashim-hq
2026-04-19 12:13:26 +08:00
parent dc7ba119f8
commit 12c4d4de6f
14 changed files with 43 additions and 39 deletions
+8 -3
View File
@@ -100,9 +100,7 @@ function startDispatcher(): ChildProcess | null {
if (parsed.ready === true) {
dispatcherReady = true;
dispatcherGpuAvailable = parsed.gpu === true;
console.log(
`[bridge] Python dispatcher ready (GPU: ${parsed.gpu === true})`,
);
console.log(`[bridge] Python dispatcher ready (GPU: ${parsed.gpu === true})`);
continue;
}
@@ -408,3 +406,10 @@ export function runPythonWithProgress(
// Fall back to per-request spawning
return runPythonPerRequest(scriptName, args, options);
}
// biome-ignore lint/suspicious/noExplicitAny: matches JSON.parse return type
export function parseStdoutJson(stdout: string): any {
const match = stdout.match(/\{[\s\S]*\}$/);
if (!match) throw new Error("No JSON response from Python script");
return JSON.parse(match[0]);
}