1+ import fs from "node:fs/promises" ;
2+ import os from "node:os" ;
3+ import path from "node:path" ;
14import { afterEach , beforeEach , describe , expect , it } from "vitest" ;
25import {
36 cleanupTempPaths ,
@@ -22,13 +25,15 @@ describe("runEmbeddedAttempt cwd/workspace split", () => {
2225
2326 it ( "uses workspace for bootstrap and cwd for runtime tools" , async ( ) => {
2427 const bootstrap = createContextEngineBootstrapAndAssemble ( ) ;
28+ const taskRepo = await fs . mkdtemp ( path . join ( os . tmpdir ( ) , "openclaw-task-repo-" ) ) ;
29+ tempPaths . push ( taskRepo ) ;
2530
2631 await createContextEngineAttemptRunner ( {
2732 contextEngine : bootstrap ,
2833 sessionKey : "agent:main:subagent:child" ,
2934 tempPaths,
3035 attemptOverrides : {
31- cwd : "/tmp/task-repo" ,
36+ cwd : taskRepo ,
3237 disableTools : false ,
3338 } ,
3439 } ) ;
@@ -42,14 +47,14 @@ describe("runEmbeddedAttempt cwd/workspace split", () => {
4247 const toolsCall = hoisted . createOpenClawCodingToolsMock . mock . calls [ 0 ] ?. [ 0 ] as
4348 | { cwd ?: string ; workspaceDir ?: string ; spawnWorkspaceDir ?: string }
4449 | undefined ;
45- expect ( toolsCall ?. cwd ) . toBe ( "/tmp/task-repo" ) ;
50+ expect ( toolsCall ?. cwd ) . toBe ( taskRepo ) ;
4651 expect ( toolsCall ?. workspaceDir ) . toBe ( bootstrapCall ?. workspaceDir ) ;
4752 expect ( toolsCall ?. spawnWorkspaceDir ) . toBe ( bootstrapCall ?. workspaceDir ) ;
4853
4954 const resourceLoaderInit = hoisted . defaultResourceLoaderInitMock . mock . calls [ 0 ] ?. [ 0 ] as
5055 | { cwd ?: string }
5156 | undefined ;
52- expect ( resourceLoaderInit ?. cwd ) . toBe ( "/tmp/task-repo" ) ;
57+ expect ( resourceLoaderInit ?. cwd ) . toBe ( taskRepo ) ;
5358 } ) ;
5459
5560 it ( "rejects cwd overrides for sandboxed runs instead of silently ignoring them" , async ( ) => {
0 commit comments