fix(v2): strip all CLAUDE* env vars in sidecar to prevent CLI nesting detection
When BTerminal is launched from a Claude Code terminal, ~8 CLAUDE* env vars leak into the sidecar child processes. The claude CLI detects these as nesting indicators and silently hangs. Previously only CLAUDECODE was removed; now all CLAUDE-prefixed vars are stripped in both Node.js and Deno sidecar runners.
This commit is contained in:
parent
4c06b5f121
commit
ce79ae671a
2 changed files with 17 additions and 7 deletions
|
|
@ -66,8 +66,13 @@ function handleQuery(msg: QueryMessage) {
|
|||
|
||||
log(`Starting agent session ${sessionId}: claude ${args.join(" ")}`);
|
||||
|
||||
const env = { ...Deno.env.toObject() };
|
||||
delete env.CLAUDECODE;
|
||||
// Strip all CLAUDE* env vars to prevent nesting detection by claude CLI
|
||||
const env: Record<string, string> = {};
|
||||
for (const [key, value] of Object.entries(Deno.env.toObject())) {
|
||||
if (!key.startsWith("CLAUDE")) {
|
||||
env[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
const command = new Deno.Command("claude", {
|
||||
args,
|
||||
|
|
|
|||
|
|
@ -89,13 +89,18 @@ function handleQuery(msg: QueryMessage) {
|
|||
|
||||
log(`Starting agent session ${sessionId}: claude ${args.join(' ')}`);
|
||||
|
||||
// Strip all CLAUDE* env vars to prevent nesting detection by claude CLI.
|
||||
// When BTerminal is launched from a Claude Code terminal, these leak in.
|
||||
const cleanEnv: Record<string, string> = {};
|
||||
for (const [key, value] of Object.entries(process.env)) {
|
||||
if (!key.startsWith('CLAUDE') && value !== undefined) {
|
||||
cleanEnv[key] = value;
|
||||
}
|
||||
}
|
||||
|
||||
const child = spawn('claude', args, {
|
||||
cwd: cwd || process.cwd(),
|
||||
env: {
|
||||
...process.env,
|
||||
// Unset CLAUDECODE to avoid nesting detection
|
||||
CLAUDECODE: undefined,
|
||||
},
|
||||
env: cleanEnv,
|
||||
stdio: ['pipe', 'pipe', 'pipe'],
|
||||
});
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue