mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-05 18:10:21 +00:00
27 lines
768 B
TypeScript
27 lines
768 B
TypeScript
import { wrapToolWorkspaceRootGuardWithOptions } from "./pi-tools.read.js";
|
|
import type { ToolFsPolicy } from "./tool-fs-policy.js";
|
|
import type { AnyAgentTool } from "./tools/common.js";
|
|
|
|
export function applyNodesToolWorkspaceGuard(
|
|
nodesToolBase: AnyAgentTool,
|
|
options: {
|
|
fsPolicy?: ToolFsPolicy;
|
|
sandboxContainerWorkdir?: string;
|
|
sandboxRoot?: string;
|
|
workspaceDir: string;
|
|
},
|
|
): AnyAgentTool {
|
|
if (options.fsPolicy?.workspaceOnly !== true) {
|
|
return nodesToolBase;
|
|
}
|
|
return wrapToolWorkspaceRootGuardWithOptions(
|
|
nodesToolBase,
|
|
options.sandboxRoot ?? options.workspaceDir,
|
|
{
|
|
containerWorkdir: options.sandboxContainerWorkdir,
|
|
normalizeGuardedPathParams: true,
|
|
pathParamKeys: ["outPath"],
|
|
},
|
|
);
|
|
}
|