fix(desktop): restore daemon QR pairing output

This commit is contained in:
Mohamed Boudra
2026-04-05 00:53:46 +07:00
parent a889dbcc28
commit 5db9942125
+10 -2
View File
@@ -223,7 +223,7 @@ function createCliInvocation(args: string[]): NodeEntrypointInvocation {
const cli = resolveCliEntrypoint(); const cli = resolveCliEntrypoint();
return createNodeEntrypointInvocation({ return createNodeEntrypointInvocation({
entrypoint: cli, entrypoint: cli,
argvMode: "bare", argvMode: "node-script",
args, args,
baseEnv: process.env, baseEnv: process.env,
}); });
@@ -304,8 +304,16 @@ export async function runCliJsonCommand(args: string[]): Promise<unknown> {
throw new Error("CLI command did not produce JSON output."); throw new Error("CLI command did not produce JSON output.");
} }
// The stdout may contain non-JSON preamble (e.g. Node deprecation warnings).
// Extract the first valid JSON object or array from the output.
const jsonStart = stdout.search(/[{[]/);
if (jsonStart < 0) {
throw new Error("CLI command output contained no JSON.");
}
const jsonText = stdout.slice(jsonStart);
try { try {
return JSON.parse(stdout) as unknown; return JSON.parse(jsonText) as unknown;
} catch (error) { } catch (error) {
throw new Error( throw new Error(
`CLI command returned invalid JSON: ${error instanceof Error ? error.message : String(error)}`, `CLI command returned invalid JSON: ${error instanceof Error ? error.message : String(error)}`,