mirror of
https://github.com/tiennm99/ccs.git
synced 2026-10-14 08:18:04 +00:00
fix(delegation): strip claudecode in core delegation spawn paths
- add shared CLAUDECODE sanitizer for child env construction - apply sanitizer in execClaude and headless delegation execution - sanitize GLMT embedded Claude spawn environment Refs #588
This commit is contained in:
1 parent
4303ee48c9
commit
50412dc679
3 files changed
+23
-6
No files matched your search
@@ -24,6 +24,22 @@ export function stripAnthropicEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Strip Claude Code nested-session guard env var from a process environment.
|
||||
*
|
||||
* Note: Windows env keys are case-insensitive, so remove case-insensitively
|
||||
* to avoid missing variants like `claudecode`.
|
||||
*/
|
||||
export function stripClaudeCodeEnv(env: NodeJS.ProcessEnv): NodeJS.ProcessEnv {
|
||||
const result: NodeJS.ProcessEnv = {};
|
||||
for (const key of Object.keys(env)) {
|
||||
if (key.toUpperCase() !== 'CLAUDECODE') {
|
||||
result[key] = env[key];
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Escape arguments for shell execution (cross-platform)
|
||||
*
|
||||
@@ -80,13 +96,13 @@ export function execClaude(
|
||||
: process.env;
|
||||
|
||||
// Prepare environment (merge with base env if envVars provided)
|
||||
const env = envVars
|
||||
const mergedEnv = envVars
|
||||
? { ...baseEnv, ...envVars, ...webSearchEnv }
|
||||
: { ...baseEnv, ...webSearchEnv };
|
||||
|
||||
// Strip Claude Code nested session guard env var to allow CCS delegation
|
||||
// (Claude Code v2.1.39+ sets CLAUDECODE to detect nested sessions)
|
||||
delete env.CLAUDECODE;
|
||||
const env = stripClaudeCodeEnv(mergedEnv);
|
||||
|
||||
// propagate key env vars to tmux session so agent team teammates
|
||||
// (spawned via tmux split-window) inherit the correct config dir
|
||||
|
||||
Reference in new issue
Block a user