From b26c8eadaa21d1d17870d0976b9862aa0b486853 Mon Sep 17 00:00:00 2001 From: Cameron Date: Fri, 30 Jan 2026 12:13:29 -0800 Subject: [PATCH] fix: log CLI stderr and exit codes for debugging (#11) Co-authored-by: Letta --- src/transport.ts | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/src/transport.ts b/src/transport.ts index 8ce1742..92da92f 100644 --- a/src/transport.ts +++ b/src/transport.ts @@ -28,6 +28,10 @@ export class SubprocessTransport { // Find the CLI - use the installed letta-code package const cliPath = await this.findCli(); + if (process.env.DEBUG) { + console.log("[letta-code-sdk] Using CLI:", cliPath); + console.log("[letta-code-sdk] Args:", args.join(" ")); + } this.process = spawn("node", [cliPath, ...args], { cwd: this.options.cwd || process.cwd(), @@ -55,13 +59,26 @@ export class SubprocessTransport { } }); + // Log stderr for debugging (CLI errors, auth failures, etc.) + if (this.process.stderr) { + this.process.stderr.on("data", (data: Buffer) => { + const msg = data.toString().trim(); + if (msg) { + console.error("[letta-code-sdk] CLI stderr:", msg); + } + }); + } + // Handle process exit - this.process.on("close", () => { + this.process.on("close", (code) => { this.closed = true; + if (code !== 0 && code !== null) { + console.error(`[letta-code-sdk] CLI process exited with code ${code}`); + } }); this.process.on("error", (err) => { - console.error("CLI process error:", err); + console.error("[letta-code-sdk] CLI process error:", err); this.closed = true; }); }