@@ -12,6 +12,9 @@ import { formatDocsLink } from "../../packages/terminal-core/src/links.js";
1212import { colorize , isRich , theme } from "../../packages/terminal-core/src/theme.js" ;
1313import { resolveAgentConfig } from "../agents/agent-scope.js" ;
1414import { resolveSandboxConfigForAgent } from "../agents/sandbox.js" ;
15+ import { getSandboxBackendWorkdirResolver } from "../agents/sandbox/backend.js" ;
16+ import { buildSandboxFsMounts } from "../agents/sandbox/fs-paths.js" ;
17+ import { resolveSandboxWorkspaceLayoutPaths } from "../agents/sandbox/shared.js" ;
1518import { resolveSandboxToolPolicyForAgent } from "../agents/sandbox/tool-policy.js" ;
1619import { normalizeAnyChannelId } from "../channels/registry.js" ;
1720import { getRuntimeConfig } from "../config/config.js" ;
@@ -171,6 +174,33 @@ export async function sandboxExplainCommand(
171174 } ) ;
172175
173176 const sandboxCfg = resolveSandboxConfigForAgent ( cfg , resolvedAgentId ) ;
177+ const agentConfig = resolveAgentConfig ( cfg , resolvedAgentId ) ;
178+ const workspaceLayout = resolveSandboxWorkspaceLayoutPaths ( {
179+ cfg : sandboxCfg ,
180+ rawSessionKey : sessionKey ,
181+ workspaceDir : agentConfig ?. workspace ,
182+ } ) ;
183+ const containerWorkdir =
184+ getSandboxBackendWorkdirResolver ( sandboxCfg . backend ) ?.( {
185+ sessionKey,
186+ scopeKey : workspaceLayout . scopeKey ,
187+ workspaceDir : workspaceLayout . workspaceDir ,
188+ agentWorkspaceDir : workspaceLayout . agentWorkspaceDir ,
189+ skillsWorkspaceDir : workspaceLayout . skillsWorkspaceDir ,
190+ cfg : sandboxCfg ,
191+ } ) ?? sandboxCfg . docker . workdir ;
192+ const workspaceMounts =
193+ sandboxCfg . backend === "docker"
194+ ? buildSandboxFsMounts ( {
195+ workspaceDir : workspaceLayout . workspaceDir ,
196+ agentWorkspaceDir : workspaceLayout . agentWorkspaceDir ,
197+ skillsWorkspaceDir : workspaceLayout . skillsWorkspaceDir ,
198+ workspaceAccess : sandboxCfg . workspaceAccess ,
199+ containerName : "" ,
200+ containerWorkdir,
201+ docker : sandboxCfg . docker ,
202+ } )
203+ : [ ] ;
174204 const toolPolicy = resolveSandboxToolPolicyForAgent ( cfg , resolvedAgentId ) ;
175205 const mainSessionKey = resolveAgentMainSessionKey ( {
176206 cfg,
@@ -189,7 +219,6 @@ export async function sandboxExplainCommand(
189219 sessionKey,
190220 } ) ;
191221
192- const agentConfig = resolveAgentConfig ( cfg , resolvedAgentId ) ;
193222 const elevatedGlobal = cfg . tools ?. elevated ;
194223 const elevatedAgent = agentConfig ?. tools ?. elevated ;
195224 const elevatedGlobalEnabled = elevatedGlobal ?. enabled !== false ;
@@ -264,7 +293,13 @@ export async function sandboxExplainCommand(
264293 mode : sandboxCfg . mode ,
265294 scope : sandboxCfg . scope ,
266295 workspaceAccess : sandboxCfg . workspaceAccess ,
267- workspaceRoot : sandboxCfg . workspaceRoot ,
296+ workspaceRoot : workspaceLayout . workspaceDir ,
297+ configuredWorkspaceRoot : sandboxCfg . workspaceRoot ,
298+ sandboxWorkspaceRoot : workspaceLayout . sandboxWorkspaceDir ,
299+ agentWorkspaceRoot : workspaceLayout . agentWorkspaceDir ,
300+ containerWorkdir,
301+ workspaceMounts,
302+ workspaceSource : workspaceLayout . workspaceSource ,
268303 sessionIsSandboxed,
269304 tools : {
270305 allow : toolPolicy . allow ,
@@ -318,6 +353,24 @@ export async function sandboxExplainCommand(
318353 payload . sandbox . workspaceAccess ,
319354 ) } ${ key ( "workspaceRoot:" ) } ${ value ( payload . sandbox . workspaceRoot ) } `,
320355 ) ;
356+ lines . push (
357+ ` ${ key ( "configuredWorkspaceRoot:" ) } ${ value ( payload . sandbox . configuredWorkspaceRoot ) } ` ,
358+ ) ;
359+ lines . push (
360+ ` ${ key ( "containerWorkdir:" ) } ${ value (
361+ payload . sandbox . containerWorkdir ,
362+ ) } ${ key ( "workspaceSource:" ) } ${ value ( payload . sandbox . workspaceSource ) } `,
363+ ) ;
364+ if ( payload . sandbox . workspaceMounts . length > 0 ) {
365+ lines . push ( ` ${ key ( "workspaceMounts:" ) } ` ) ;
366+ for ( const mount of payload . sandbox . workspaceMounts ) {
367+ lines . push (
368+ ` - ${ value ( mount . hostRoot ) } -> ${ value ( mount . containerRoot ) } ${ key (
369+ mount . writable ? "rw" : "ro" ,
370+ ) } ${ key ( `(${ mount . source } )` ) } `,
371+ ) ;
372+ }
373+ }
321374 lines . push ( "" ) ;
322375 lines . push ( heading ( "Sandbox tool policy:" ) ) ;
323376 lines . push (
0 commit comments