mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-13 00:32:54 +00:00
refactor: extract shared sandbox and gateway plumbing
This commit is contained in:
28
src/agents/sandbox/workspace-mounts.ts
Normal file
28
src/agents/sandbox/workspace-mounts.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import { SANDBOX_AGENT_WORKSPACE_MOUNT } from "./constants.js";
|
||||
import type { SandboxWorkspaceAccess } from "./types.js";
|
||||
|
||||
function mainWorkspaceMountSuffix(access: SandboxWorkspaceAccess): "" | ":ro" {
|
||||
return access === "rw" ? "" : ":ro";
|
||||
}
|
||||
|
||||
function agentWorkspaceMountSuffix(access: SandboxWorkspaceAccess): "" | ":ro" {
|
||||
return access === "ro" ? ":ro" : "";
|
||||
}
|
||||
|
||||
export function appendWorkspaceMountArgs(params: {
|
||||
args: string[];
|
||||
workspaceDir: string;
|
||||
agentWorkspaceDir: string;
|
||||
workdir: string;
|
||||
workspaceAccess: SandboxWorkspaceAccess;
|
||||
}) {
|
||||
const { args, workspaceDir, agentWorkspaceDir, workdir, workspaceAccess } = params;
|
||||
|
||||
args.push("-v", `${workspaceDir}:${workdir}${mainWorkspaceMountSuffix(workspaceAccess)}`);
|
||||
if (workspaceAccess !== "none" && workspaceDir !== agentWorkspaceDir) {
|
||||
args.push(
|
||||
"-v",
|
||||
`${agentWorkspaceDir}:${SANDBOX_AGENT_WORKSPACE_MOUNT}${agentWorkspaceMountSuffix(workspaceAccess)}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user