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
方法摘要Method Summary
构造器详情Constructor Detail
FilesystemTool
public FilesystemTool(AbstractFilesystem abstractFilesystem)
初始化 FilesystemTool 实例。
Creates a new instance.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
abstractFilesystem | AbstractFilesystem | 抽象文件系统(类型 `AbstractFilesystem`)。The abstract filesystem. |
源码Source
io/agentscope/harness/agent/tool/FilesystemTool.java:46–48FilesystemTool
public FilesystemTool(AbstractFilesystem abstractFilesystem, WorkspacePathNormalizer pathNormalizer)
初始化 FilesystemTool 实例。
Creates a new instance.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
abstractFilesystem | AbstractFilesystem | 抽象文件系统(类型 `AbstractFilesystem`)。The abstract filesystem. |
pathNormalizer | WorkspacePathNormalizer | 路径 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 |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
path | String | 路径(类型 `String`)。The path. |
offset | Integer | 偏移量(类型 `Integer`)。The offset. |
limit | Integer | 数量上限(类型 `Integer`)。The limit. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/agent/tool/FilesystemTool.java:110–137writeFile
public String writeFile(RuntimeContext runtimeContext, String path, String content)
执行写入文件相关操作。
Performs the write file operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
path | String | 路径(类型 `String`)。The path. |
content | String | 内容(类型 `String`)。The content. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/agent/tool/FilesystemTool.java:139–149editFile
public String editFile(RuntimeContext runtimeContext, String path, String oldString, String newString, Boolean replaceAll)
执行 editFile 方法。
Performs the edit file operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
path | String | 路径(类型 `String`)。The path. |
oldString | String | 旧的 String(类型 `String`)。The old string. |
newString | String | 新建 String(类型 `String`)。The new string. |
replaceAll | Boolean | replace 所有(类型 `Boolean`)。The replace all. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/agent/tool/FilesystemTool.java:151–177grepFiles
public String grepFiles(RuntimeContext runtimeContext, String pattern, String path, String glob, Integer limit)
执行 grepFiles 方法。
Performs the grep files operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
pattern | String | pattern(类型 `String`)。The pattern. |
path | String | 路径(类型 `String`)。The path. |
glob | String | glob(类型 `String`)。The glob. |
limit | Integer | 数量上限(类型 `Integer`)。The limit. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/agent/tool/FilesystemTool.java:179–221grepFiles
public String grepFiles(RuntimeContext runtimeContext, String pattern, String path, String glob)
执行 grepFiles 方法。
Search using the default result limit.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
pattern | String | pattern(类型 `String`)。The pattern. |
path | String | 路径(类型 `String`)。The path. |
glob | String | glob(类型 `String`)。The glob. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/agent/tool/FilesystemTool.java:224–227globFiles
public String globFiles(RuntimeContext runtimeContext, String pattern, String path, Integer limit)
执行 globFiles 方法。
Performs the glob files operation.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
pattern | String | pattern(类型 `String`)。The pattern. |
path | String | 路径(类型 `String`)。The path. |
limit | Integer | 数量上限(类型 `Integer`)。The limit. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/agent/tool/FilesystemTool.java:229–269globFiles
public String globFiles(RuntimeContext runtimeContext, String pattern, String path)
执行 globFiles 方法。
Search using the default result limit.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
pattern | String | pattern(类型 `String`)。The pattern. |
path | String | 路径(类型 `String`)。The path. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/agent/tool/FilesystemTool.java:272–274listFiles
public String listFiles(RuntimeContext runtimeContext, String path)
列出文件。
Lists the files.
参数Parameters
| 名称Name | 类型Type | 说明Description |
|---|---|---|
runtimeContext | RuntimeContext | 运行时上下文(类型 `RuntimeContext`)。The runtime context. |
path | String | 路径(类型 `String`)。The path. |
String返回字符串结果。Returns a string.
源码Source
io/agentscope/harness/agent/tool/FilesystemTool.java:283–310