mirror of
https://github.com/cexll/myclaude.git
synced 2026-02-28 09:23:05 +08:00
fix(executor): unset CLAUDECODE env to prevent nested session rejection
Claude Code v2.1.41+ sets CLAUDECODE=1 in all child Bash processes and rejects startup when the variable is present. When codeagent-wrapper spawns `claude -p` as a subprocess, it inherits this variable and gets blocked with "cannot be launched inside another Claude Code session". Add UnsetEnv method to commandRunner interface and strip CLAUDECODE before spawning the claude backend. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -274,6 +274,10 @@ func (d *drainBlockingCmd) Process() executor.ProcessHandle {
|
||||
return d.inner.Process()
|
||||
}
|
||||
|
||||
func (d *drainBlockingCmd) UnsetEnv(keys ...string) {
|
||||
d.inner.UnsetEnv(keys...)
|
||||
}
|
||||
|
||||
type bufferWriteCloser struct {
|
||||
buf bytes.Buffer
|
||||
mu sync.Mutex
|
||||
@@ -568,6 +572,14 @@ func (f *fakeCmd) Process() executor.ProcessHandle {
|
||||
return f.process
|
||||
}
|
||||
|
||||
func (f *fakeCmd) UnsetEnv(keys ...string) {
|
||||
f.mu.Lock()
|
||||
defer f.mu.Unlock()
|
||||
for _, k := range keys {
|
||||
delete(f.env, k)
|
||||
}
|
||||
}
|
||||
|
||||
func (f *fakeCmd) runStdoutScript() {
|
||||
if len(f.stdoutPlan) == 0 {
|
||||
if !f.keepStdoutOpen {
|
||||
|
||||
Reference in New Issue
Block a user