User and working directory
The AgentBox base image runs commands as user and starts in /home/user. Other OCI images keep the user and working directory defined by that image.
setUser("guest") changes the user for following instructions but keeps the current working directory. setWorkdir("/app") selects a directory explicitly and creates it when needed.
The last values are stored in the template. As a result, commands.run in a new sandbox starts with the same user and working directory.
Order matters: create the user and grant the required permissions before you switch with setUser, then call setWorkdir when that user needs another directory. You can also pass a user to one runCmd call without changing later instructions.
See Template definition for a complete example.