Appearance
Class: FileSystem
📖 Related Tutorial
- File Operations Guide - Complete guide to file system operations
Overview
The File System module provides comprehensive file and directory operations within the AGB cloud environment. It supports file upload, download, and manipulation.
File system module for reading, writing, listing, and managing files in the session. Supports text and binary files, directory listing, search, upload/download, and file change monitoring.
Hierarchy
BaseService↳
FileSystem
Table of contents
Properties
Methods
- callMcpTool
- createDirectory
- deleteFile
- download
- editFile
- handleError
- listDirectory
- moveFile
- read
- readFile
- readMultipleFiles
- searchFiles
- toJSON
- transferPath
- upload
- watchDir
- watchDirectory
- writeFile
Properties
typescript
delete: (`path`: `string`) => `Promise`<``BoolResult``>
list: (`path`: `string`) => `Promise`<``DirectoryListResult``>
ls: (`path`: `string`) => `Promise`<``DirectoryListResult``>
mkdir: (`path`: `string`) => `Promise`<``BoolResult``>
remove: (`path`: `string`) => `Promise`<``BoolResult``>
rm: (`path`: `string`) => `Promise`<``BoolResult``>
write: (`path`: `string`, `content`: `string`, `mode`: ``"overwrite"`` | ``"append"`` | ``"create_new"``) => `Promise`<``BoolResult``>DEFAULT_CHUNK_SIZE
▪ Static Readonly DEFAULT_CHUNK_SIZE: number = DEFAULT_CHUNK_SIZE
Type declaration
▸ (path): Promise<BoolResult>
Parameters
| Name | Type |
|---|---|
path | string |
Returns
Promise<BoolResult>
Type declaration
▸ (path): Promise<DirectoryListResult>
Parameters
| Name | Type |
|---|---|
path | string |
Returns
Promise<DirectoryListResult>
Type declaration
▸ (path): Promise<DirectoryListResult>
Parameters
| Name | Type |
|---|---|
path | string |
Returns
Promise<DirectoryListResult>
Type declaration
▸ (path): Promise<BoolResult>
Parameters
| Name | Type |
|---|---|
path | string |
Returns
Promise<BoolResult>
Type declaration
▸ (path): Promise<BoolResult>
Parameters
| Name | Type |
|---|---|
path | string |
Returns
Promise<BoolResult>
Type declaration
▸ (path): Promise<BoolResult>
Parameters
| Name | Type |
|---|---|
path | string |
Returns
Promise<BoolResult>
session
• Protected session: SessionLike
Inherited from
BaseService.session
Type declaration
▸ (path, content, mode?): Promise<BoolResult>
Parameters
| Name | Type | Default value |
|---|---|---|
path | string | undefined |
content | string | undefined |
mode | "overwrite" | "append" | "create_new" | "overwrite" |
Returns
Promise<BoolResult>
Methods
callMcpTool
▸ callMcpTool(name, args, readTimeout?, connectTimeout?): Promise<OperationResult>
Parameters
| Name | Type |
|---|---|
name | string |
args | Record<string, unknown> |
readTimeout? | number |
connectTimeout? | number |
Returns
Promise<OperationResult>
Inherited from
BaseService.callMcpTool
createDirectory
▸ createDirectory(path): Promise<BoolResult>
Parameters
| Name | Type |
|---|---|
path | string |
Returns
Promise<BoolResult>
deleteFile
▸ deleteFile(path): Promise<BoolResult>
Parameters
| Name | Type |
|---|---|
path | string |
Returns
Promise<BoolResult>
download
▸ download(remotePath, localPath, options?): Promise<DownloadResult>
Parameters
| Name | Type |
|---|---|
remotePath | string |
localPath | string |
options? | Object |
options.overwrite? | boolean |
options.pollInterval? | number |
options.progressCallback? | (bytesReceived: number) => void |
options.wait? | boolean |
options.waitTimeout? | number |
Returns
Promise<DownloadResult>
editFile
▸ editFile(path, edits, dryRun?): Promise<BoolResult>
Parameters
| Name | Type | Default value |
|---|---|---|
path | string | undefined |
edits | { newText: string ; oldText: string }[] | undefined |
dryRun | boolean | false |
Returns
Promise<BoolResult>
handleError
▸ handleError(e): unknown
Parameters
| Name | Type |
|---|---|
e | unknown |
Returns
unknown
Inherited from
BaseService.handleError
listDirectory
▸ listDirectory(path): Promise<DirectoryListResult>
Parameters
| Name | Type |
|---|---|
path | string |
Returns
Promise<DirectoryListResult>
moveFile
▸ moveFile(source, destination): Promise<BoolResult>
Parameters
| Name | Type |
|---|---|
source | string |
destination | string |
Returns
Promise<BoolResult>
read
▸ read(path): Promise<FileContentResult>
Parameters
| Name | Type |
|---|---|
path | string |
Returns
Promise<FileContentResult>
▸ read(path, opts): Promise<FileContentResult>
Parameters
| Name | Type |
|---|---|
path | string |
opts | Object |
opts.format | "text" |
Returns
Promise<FileContentResult>
▸ read(path, opts): Promise<BinaryFileContentResult>
Parameters
| Name | Type |
|---|---|
path | string |
opts | Object |
opts.format | "bytes" |
Returns
Promise<BinaryFileContentResult>
readFile
▸ readFile(path): Promise<FileContentResult>
Parameters
| Name | Type |
|---|---|
path | string |
Returns
Promise<FileContentResult>
▸ readFile(path, opts): Promise<FileContentResult>
Parameters
| Name | Type |
|---|---|
path | string |
opts | Object |
opts.format | "text" |
Returns
Promise<FileContentResult>
▸ readFile(path, opts): Promise<BinaryFileContentResult>
Parameters
| Name | Type |
|---|---|
path | string |
opts | Object |
opts.format | "bytes" |
Returns
Promise<BinaryFileContentResult>
readMultipleFiles
▸ readMultipleFiles(paths): Promise<MultipleFileContentResult>
Parameters
| Name | Type |
|---|---|
paths | string[] |
Returns
Promise<MultipleFileContentResult>
searchFiles
▸ searchFiles(path, pattern, excludePatterns?): Promise<FileSearchResult>
Parameters
| Name | Type |
|---|---|
path | string |
pattern | string |
excludePatterns? | string[] |
Returns
Promise<FileSearchResult>
toJSON
▸ toJSON(): Record<string, unknown>
Returns
Record<string, unknown>
Inherited from
BaseService.toJSON
transferPath
▸ transferPath(): Promise<undefined | string>
Returns
Promise<undefined | string>
upload
▸ upload(localPath, remotePath, options?): Promise<UploadResult>
Parameters
| Name | Type |
|---|---|
localPath | string |
remotePath | string |
options? | Object |
options.contentType? | string |
options.pollInterval? | number |
options.progressCallback? | (bytesSent: number) => void |
options.wait? | boolean |
options.waitTimeout? | number |
Returns
Promise<UploadResult>
watchDir
▸ watchDir(dirPath, callback, interval?): Object
Parameters
| Name | Type | Default value |
|---|---|---|
dirPath | string | undefined |
callback | (events: FileChangeEvent[]) => void | undefined |
interval | number | 1000 |
Returns
Object
| Name | Type |
|---|---|
stop | () => void |
Deprecated
Use watchDirectory instead
watchDirectory
▸ watchDirectory(path, callback, interval?, signal?): Promise<void>
Parameters
| Name | Type | Default value |
|---|---|---|
path | string | undefined |
callback | (events: FileChangeEvent[]) => void | undefined |
interval | number | 1000 |
signal? | AbortSignal | undefined |
Returns
Promise<void>
writeFile
▸ writeFile(path, content, mode?): Promise<BoolResult>
Parameters
| Name | Type | Default value |
|---|---|---|
path | string | undefined |
content | string | undefined |
mode | "overwrite" | "append" | "create_new" | "overwrite" |
Returns
Promise<BoolResult>
Best Practices
- Always check file permissions before operations
- Use appropriate file paths and handle path separators correctly
- Clean up temporary files after operations
- Handle file operation errors gracefully
- Use streaming for large file operations