Skip to content

Commit a9f1e76

Browse files
fix(claude-sm): preserve TTY for interactive mode
- Use 'inherit' stdio when stdout is TTY - Fixes 'Input must be provided for --print' error - Claude CLI detects TTY to choose interactive vs print mode
1 parent b45053b commit a9f1e76

3 files changed

Lines changed: 24 additions & 17 deletions

File tree

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@stackmemoryai/stackmemory",
3-
"version": "0.5.44",
3+
"version": "0.5.45",
44
"description": "Lossless memory runtime for AI coding tools - organizes context as a call stack instead of linear chat logs, with team collaboration and infinite retention",
55
"engines": {
66
"node": ">=20.0.0",

src/core/models/fallback-monitor.ts

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -129,25 +129,32 @@ export class FallbackMonitor {
129129
this.currentProvider = this.routerConfig.fallback?.provider || 'qwen';
130130
}
131131

132+
// Use 'inherit' for TTY to preserve interactive mode
133+
// Claude CLI checks stdout TTY to decide interactive vs print mode
134+
const isTTY = process.stdout.isTTY;
135+
132136
currentProcess = spawn(command, args, {
133-
stdio: ['inherit', 'pipe', 'pipe'],
137+
stdio: isTTY ? 'inherit' : ['inherit', 'pipe', 'pipe'],
134138
env,
135139
cwd: options.cwd,
136140
});
137141

138-
// Monitor stdout
139-
currentProcess.stdout?.on('data', (data: Buffer) => {
140-
const text = data.toString();
141-
process.stdout.write(data);
142-
this.checkForErrors(text);
143-
});
144-
145-
// Monitor stderr
146-
currentProcess.stderr?.on('data', (data: Buffer) => {
147-
const text = data.toString();
148-
process.stderr.write(data);
149-
this.checkForErrors(text);
150-
});
142+
// Only monitor output in non-TTY mode (fallback detection still works via exit code)
143+
if (!isTTY) {
144+
// Monitor stdout
145+
currentProcess.stdout?.on('data', (data: Buffer) => {
146+
const text = data.toString();
147+
process.stdout.write(data);
148+
this.checkForErrors(text);
149+
});
150+
151+
// Monitor stderr
152+
currentProcess.stderr?.on('data', (data: Buffer) => {
153+
const text = data.toString();
154+
process.stderr.write(data);
155+
this.checkForErrors(text);
156+
});
157+
}
151158

152159
// Handle exit
153160
currentProcess.on('exit', (code, _signal) => {

0 commit comments

Comments
 (0)