Package io.agentscope.harness.agent.tool
Class FilesystemTool
java.lang.Object
io.agentscope.harness.agent.tool.FilesystemTool
File system tools backed by a
AbstractFilesystem, exposing read/write/edit/grep/glob
operations as agent-callable tools.-
Constructor Summary
ConstructorsConstructorDescriptionFilesystemTool(AbstractFilesystem abstractFilesystem) FilesystemTool(AbstractFilesystem abstractFilesystem, WorkspacePathNormalizer pathNormalizer) -
Method Summary
Modifier and TypeMethodDescriptioneditFile(io.agentscope.core.agent.RuntimeContext runtimeContext, String path, String oldString, String newString, Boolean replaceAll) Search using the default result limit.globFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, String pattern, String path, Integer limit) grepFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, String pattern, String path, String glob) Search using the default result limit.grepFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, String pattern, String path, String glob, Integer limit) readFile(io.agentscope.core.agent.RuntimeContext runtimeContext, String path, Integer offset, Integer limit)
-
Constructor Details
-
FilesystemTool
-
FilesystemTool
public FilesystemTool(AbstractFilesystem abstractFilesystem, WorkspacePathNormalizer pathNormalizer)
-
-
Method Details
-
readFile
@Tool(name="read_file", readOnly=true, description="Read file content with line numbers. Supports pagination via offset and limit.") public String readFile(io.agentscope.core.agent.RuntimeContext runtimeContext, @ToolParam(name="path",description="File path to read") String path, @ToolParam(name="offset",description="Start line (0-indexed). Default: 0 (from beginning)",required=false) Integer offset, @ToolParam(name="limit",description="Max lines to return. Default: 0 (all lines)",required=false) Integer limit) -
writeFile
@Tool(name="write_file", description="Write content to a new file, creating parent directories if needed.") public String writeFile(io.agentscope.core.agent.RuntimeContext runtimeContext, @ToolParam(name="path",description="Target file path") String path, @ToolParam(name="content",description="File content to write") String content) -
editFile
@Tool(name="edit_file", description="Perform exact string replacement in a file. The old_string must be unique unless replace_all is true.") public String editFile(io.agentscope.core.agent.RuntimeContext runtimeContext, @ToolParam(name="path",description="File to edit") String path, @ToolParam(name="old_string",description="Text to find") String oldString, @ToolParam(name="new_string",description="Replacement text") String newString, @ToolParam(name="replace_all",description="Replace all occurrences (default: false)",required=false) Boolean replaceAll) -
grepFiles
@Tool(name="grep_files", readOnly=true, description="Search file contents for a literal text pattern. Returns at most 100 matches by default to keep tool output bounded.") public String grepFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, @ToolParam(name="pattern",description="Literal text pattern to search for") String pattern, @ToolParam(name="path",description="Directory or file to search",required=false) String path, @ToolParam(name="glob",description="Optional file glob filter (e.g., *.java)",required=false) String glob, @ToolParam(name="limit",description="Maximum matches to return (default/recommended: 100; hard maximum: 1000)",required=false) Integer limit) -
grepFiles
public String grepFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, String pattern, String path, String glob) Search using the default result limit. -
globFiles
@Tool(name="glob_files", readOnly=true, description="Find files matching a glob pattern. Returns at most 200 files by default to keep tool output bounded.") public String globFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, @ToolParam(name="pattern",description="Glob pattern (e.g., **/*.java)") String pattern, @ToolParam(name="path",description="Base directory to search from",required=false) String path, @ToolParam(name="limit",description="Maximum files to return (default/recommended: 200; hard maximum: 1000)",required=false) Integer limit) -
globFiles
public String globFiles(io.agentscope.core.agent.RuntimeContext runtimeContext, String pattern, String path) Search using the default result limit. -
listFiles
-