mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 13:27:39 +00:00
refactor(agents): centralize sandbox media and fs policy helpers
This commit is contained in:
@@ -49,6 +49,7 @@ import { cleanToolSchemaForGemini, normalizeToolParameters } from "./pi-tools.sc
|
||||
import type { AnyAgentTool } from "./pi-tools.types.js";
|
||||
import type { SandboxContext } from "./sandbox.js";
|
||||
import { getSubagentDepthFromSessionStore } from "./subagent-depth.js";
|
||||
import { createToolFsPolicy } from "./tool-fs-policy.js";
|
||||
import {
|
||||
applyToolPolicyPipeline,
|
||||
buildDefaultToolPolicyPipelineSteps,
|
||||
@@ -291,11 +292,14 @@ export function createOpenClawCodingTools(options?: {
|
||||
]);
|
||||
const execConfig = resolveExecConfig({ cfg: options?.config, agentId });
|
||||
const fsConfig = resolveFsConfig({ cfg: options?.config, agentId });
|
||||
const fsPolicy = createToolFsPolicy({
|
||||
workspaceOnly: fsConfig.workspaceOnly,
|
||||
});
|
||||
const sandboxRoot = sandbox?.workspaceDir;
|
||||
const sandboxFsBridge = sandbox?.fsBridge;
|
||||
const allowWorkspaceWrites = sandbox?.workspaceAccess !== "ro";
|
||||
const workspaceRoot = resolveWorkspaceRoot(options?.workspaceDir);
|
||||
const workspaceOnly = fsConfig.workspaceOnly === true;
|
||||
const workspaceOnly = fsPolicy.workspaceOnly;
|
||||
const applyPatchConfig = execConfig.applyPatch;
|
||||
// Secure by default: apply_patch is workspace-contained unless explicitly disabled.
|
||||
// (tools.fs.workspaceOnly is a separate umbrella flag for read/write/edit/apply_patch.)
|
||||
@@ -458,7 +462,7 @@ export function createOpenClawCodingTools(options?: {
|
||||
agentDir: options?.agentDir,
|
||||
sandboxRoot,
|
||||
sandboxFsBridge,
|
||||
workspaceOnly,
|
||||
fsPolicy,
|
||||
workspaceDir: workspaceRoot,
|
||||
sandboxed: !!sandbox,
|
||||
config: options?.config,
|
||||
|
||||
Reference in New Issue
Block a user