AS AgentScopeAPI 手册 / API Reference

FilesystemTool

public class FilesystemTool
源码Source io/agentscope/harness/agent/tool/FilesystemTool.java:37–311

文件系统工具,封装可被智能体调用的能力。位于 io.agentscope.harness.agent.tool 包。核心成员包括 readFile、writeFile、editFile、grepFiles、globFiles、listFiles。

File system tools backed by a AbstractFilesystem, exposing read/write/edit/grep/glob operations as agent-callable tools.

构造器摘要Constructor Summary

构造器Constructor说明Description
public FilesystemTool(AbstractFilesystem abstractFilesystem)
初始化 `FilesystemTool` 实例。
Creates a new instance.
public FilesystemTool(AbstractFilesystem abstractFilesystem, WorkspacePathNormalizer pathNormalizer)
初始化 `FilesystemTool` 实例。
Creates a new instance.

方法摘要Method Summary

方法Method说明Description
public String readFile(RuntimeContext runtimeContext, String path, Integer offset, Integer limit)
执行读取文件相关操作。
Performs the read file operation.
public String writeFile(RuntimeContext runtimeContext, String path, String content)
执行写入文件相关操作。
Performs the write file operation.
public String editFile(RuntimeContext runtimeContext, String path, String oldString, String newString, Boolean replaceAll)
执行 `editFile` 方法。
Performs the edit file operation.
public String grepFiles(RuntimeContext runtimeContext, String pattern, String path, String glob, Integer limit)
执行 `grepFiles` 方法。
Performs the grep files operation.
public String grepFiles(RuntimeContext runtimeContext, String pattern, String path, String glob)
执行 `grepFiles` 方法。
Search using the default result limit.
public String globFiles(RuntimeContext runtimeContext, String pattern, String path, Integer limit)
执行 `globFiles` 方法。
Performs the glob files operation.
public String globFiles(RuntimeContext runtimeContext, String pattern, String path)
执行 `globFiles` 方法。
Search using the default result limit.
public String listFiles(RuntimeContext runtimeContext, String path)
列出文件。
Lists the files.

构造器详情Constructor Detail

FilesystemTool

public FilesystemTool(AbstractFilesystem abstractFilesystem)

初始化 FilesystemTool 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
abstractFilesystemAbstractFilesystem抽象文件系统(类型 `AbstractFilesystem`)。The abstract filesystem.
源码Source io/agentscope/harness/agent/tool/FilesystemTool.java:46–48

FilesystemTool

public FilesystemTool(AbstractFilesystem abstractFilesystem, WorkspacePathNormalizer pathNormalizer)

初始化 FilesystemTool 实例。

Creates a new instance.

参数Parameters
名称Name类型Type说明Description
abstractFilesystemAbstractFilesystem抽象文件系统(类型 `AbstractFilesystem`)。The abstract filesystem.
pathNormalizerWorkspacePathNormalizer路径 Normalizer(类型 `WorkspacePathNormalizer`)。The path normalizer.
源码Source io/agentscope/harness/agent/tool/FilesystemTool.java:50–54

方法详情Method Detail

readFile

public String readFile(RuntimeContext runtimeContext, String path, Integer offset, Integer limit)

执行读取文件相关操作。

Performs the read file operation.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
pathString路径(类型 `String`)。The path.
offsetInteger偏移量(类型 `Integer`)。The offset.
limitInteger数量上限(类型 `Integer`)。The limit.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/tool/FilesystemTool.java:110–137

writeFile

public String writeFile(RuntimeContext runtimeContext, String path, String content)

执行写入文件相关操作。

Performs the write file operation.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
pathString路径(类型 `String`)。The path.
contentString内容(类型 `String`)。The content.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/tool/FilesystemTool.java:139–149

editFile

public String editFile(RuntimeContext runtimeContext, String path, String oldString, String newString, Boolean replaceAll)

执行 editFile 方法。

Performs the edit file operation.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
pathString路径(类型 `String`)。The path.
oldStringString旧的 String(类型 `String`)。The old string.
newStringString新建 String(类型 `String`)。The new string.
replaceAllBooleanreplace 所有(类型 `Boolean`)。The replace all.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/tool/FilesystemTool.java:151–177

grepFiles

public String grepFiles(RuntimeContext runtimeContext, String pattern, String path, String glob, Integer limit)

执行 grepFiles 方法。

Performs the grep files operation.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
patternStringpattern(类型 `String`)。The pattern.
pathString路径(类型 `String`)。The path.
globStringglob(类型 `String`)。The glob.
limitInteger数量上限(类型 `Integer`)。The limit.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/tool/FilesystemTool.java:179–221

grepFiles

public String grepFiles(RuntimeContext runtimeContext, String pattern, String path, String glob)

执行 grepFiles 方法。

Search using the default result limit.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
patternStringpattern(类型 `String`)。The pattern.
pathString路径(类型 `String`)。The path.
globStringglob(类型 `String`)。The glob.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/tool/FilesystemTool.java:224–227

globFiles

public String globFiles(RuntimeContext runtimeContext, String pattern, String path, Integer limit)

执行 globFiles 方法。

Performs the glob files operation.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
patternStringpattern(类型 `String`)。The pattern.
pathString路径(类型 `String`)。The path.
limitInteger数量上限(类型 `Integer`)。The limit.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/tool/FilesystemTool.java:229–269

globFiles

public String globFiles(RuntimeContext runtimeContext, String pattern, String path)

执行 globFiles 方法。

Search using the default result limit.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
patternStringpattern(类型 `String`)。The pattern.
pathString路径(类型 `String`)。The path.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/tool/FilesystemTool.java:272–274

listFiles

public String listFiles(RuntimeContext runtimeContext, String path)

列出文件。

Lists the files.

参数Parameters
名称Name类型Type说明Description
runtimeContextRuntimeContext运行时上下文(类型 `RuntimeContext`)。The runtime context.
pathString路径(类型 `String`)。The path.
返回Returns String
返回字符串结果。Returns a string.
源码Source io/agentscope/harness/agent/tool/FilesystemTool.java:283–310
基于官方固定版本源码静态生成Generated from pinned official sources · Python 2.0.11 · Java 2.0.4
签名与文档为静态抽取;如有疑问请以源码为准。Signatures and docs are extracted statically; verify against the source when in doubt.