diff --git a/pkg/tools/shell.go b/pkg/tools/shell.go index b9103234f..9691008e9 100644 --- a/pkg/tools/shell.go +++ b/pkg/tools/shell.go @@ -149,7 +149,7 @@ func NewExecToolWithConfig(workingDir string, restrict bool, config *config.Conf } // Ensure PICOCLAW_* vars are set for child processes - envSet = shell.WithPicoclawEnvVars(envSet) + envSet = shell.WithPicoclawEnvVars(envSet, workingDir) return &ExecTool{ workingDir: workingDir, diff --git a/pkg/tools/shell/env.go b/pkg/tools/shell/env.go index 8b2bc89e4..975b0263a 100644 --- a/pkg/tools/shell/env.go +++ b/pkg/tools/shell/env.go @@ -156,7 +156,7 @@ func isAllowedPrefix(name string) bool { // WithPicoclawEnvVars ensures PICOCLAW_* vars are set in envSet. // These are needed for child processes to locate config, workspace, etc. -func WithPicoclawEnvVars(envSet map[string]string) map[string]string { +func WithPicoclawEnvVars(envSet map[string]string, workspace string) map[string]string { if envSet == nil { envSet = make(map[string]string) } @@ -174,6 +174,11 @@ func WithPicoclawEnvVars(envSet map[string]string) map[string]string { envSet["PICOCLAW_CONFIG"] = filepath.Join(home, "config.json") } + // Workspace - this is the agent's working directory + if workspace != "" { + envSet["PICOCLAW_AGENT_WORKSPACE"] = workspace + } + if exe, err := os.Executable(); err == nil { envSet["PICOCLAW_EXE"] = exe }